reshape function should change the shape of a matrix.
But if I try using it (it’s also written in the manual) I discover that if I declare:
reshape(A,m,n);
Then A must have m lines and n columns.
If I try using reshape passing as arguments numbers different from these, I get an error.
So appearently, it does not reshape any matrix, it just does return the same matrix if I pass m and n as arguments, and return an error otherwise.
So if I have a 4×4 matrix and I want to make it smaller: 2×2, I can’t.
reshape function should change the shape of a matrix. But if I try using
Share
It changes the shape, not the size of the array. To change the shape the number of elements must not change. So if you have 4×4 you can go to 8×2 or 2×8 or 16×1 etc. but not 2×2 (what do you expect to happen to the other elements?)