reshape() command or function reshapes a matrix or vector, after reading this MATLAB Reshape topic, you will know the theory and examples.
Syntax:
reshape(n,a,b)
- n is a matrix or vector.
- a is numbers of rows.
- b is numbers of columns.
Example: To reshape a vector into the matrix.
n=[1,2,3,56] reshape(n,2,2)
Output:
n = 1 2 3 56 ans = 1 3 2 56
Example: To reshape a matrix into another matrix.
n=[2,3;2,1;5,1] reshape(n,3,2)
Output:
n =
2 3
2 1
5 1
ans =
2 5 1
2 3 1