mat = vec2mat(vec,matcol) converts the vector vec into a matrix with matcol columns, creating one row at a time. If the length of vec is not a multiple of matcol, then extra zeros are placed in the last row of mat. The matrix mat has ceil(length(vec)/matcol) rows. mat = vec2mat(vec,matcol,padding) is the same as the first syntax, except that the extra entries placed in the last row of mat are not necessarily zeros. The extra entries are taken from the matrix padding, in order. If padding has fewer entries than are needed, then the last entry is used repeatedly. [mat,padded] = vec2mat(…) returns an integer padded that indicates how many extra entries were placed in the last row of mat. Note: vec2mat is similar to the built-in MATLAB® function reshape. However, given a vector input, reshape creates a matrix one column at a time instead of one row at a time. Also, reshape requires the input and output matrices to have the same number of entries, whereas vec2mat places extra entries in the output matrix if necessary. Choose your country to get translated content where available and see local events and offers. Based on your location, we recommend that you select: . Source.