In some cases again, we need to reshape a vector that includes elements to obtain a matrix, to matrix form in Matlab. There could be some situations to use it. Matlab has a command that do this kind of businnes. So in this text of Mechanicalland, we will show you how to reshape a vector to matrix form in Matlab.
How To Reshape A Vector To Matrix Form In Matlab?
To use reshape() command in Matlab, the used vector to create matrix must be fit to row and column number to desired matrix in reshape() like above.
We created a vector called ‘a’ as shown by blue arrow above then we give it a matrix form with reshape() command as shown in blue box above. We want to create a matrix has 5 rows and 3 columns from vector ‘a’. So we typed reshape(a,5,3) command to do it. As you can see above again, the 5×3 matrix is obtained with the elements of ‘a’ respectively.
So use of ‘reshape()’ command to obtain matrices from vectors is very basic in Matlab.
Leave your comments and questions below!