Hello I'm working with MATLAB and I have a "z" column vector that has dimension of (9680 x 1). I want to reshape it in order to have an array "z" of dimension (44 x 220). I'm doing the following:
z=reshape(z,44,220);
I also tried:
z=reshape(z,[44,220]);
But the output is not right (at least the first row). I can see it by comparing the output matrix with the initial vector.
I just need the 220 first positions of the column vector to be the length of the first row of the matrix, then the next 220 positions of the vector to be the second row of the matrix and so on till obtaining 44 rows.
What am I doing wrong? Thanks for your help.
Matlab stores the matrix values in column major format (this is important during reshape). Since you want row major, you need to do
i.e. transpose afterwards.
I'd use Andreas H.'s approach.
As an alternative, there's a
vec2mat
function in the Communications Toolbox that does just that, and even fills missing values if needed: