Turn a Matrix into a Row Vector in MATLAB
Conversion of a Matrix into a Row Vector. This conversion can be done using reshape() function along with the Transpose operation. This reshape() function is used to reshape the specified matrix using the given size vector.
Syntax:
reshape(A, sz)
Parameters: This function accepts two parameters, which are illustrated below:
- A: This is the specified matrix of elements.
- sz: This is the specified size vector.
Return Value: It returns the row vector of a given matrix.
Example 1
Matlab
A = [1 2; 3 4];
B = reshape(A.',1,[])
|
Output:
Example 2
Matlab
A = [1 2 3; 4 5 6; 7 8 9];
B = reshape(A.',1,[])
|
Output:
Last Updated :
04 Jul, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...