MATLAB: How can convert vector aa size 1×262144 to matrix 256×256

reshape

hi every one i'm new her i need help
size of aa 1×262144 i want convert to matrix 256×256

Best Answer

% you will not convert (262144 is 4 times 256*256 and not equal to it)
% but complete 4 matrices out of your "aa" vector
% and you will get a "M" array:
L=256*256;
M=nan(256,256,4); % pre-allocate
for i=1:4
v=aa(L*(i-1)+1:L*i);
M(:,:,i)=reshape(v,256,256);
end