Reshaping MATLAB matrix in a particular way

Viewed 91

I am working on a MATLAB code so that I can basically do this

enter image description here

To accomlish that, my code looks like this

A = [1:30]'; % Example matrix
rows = 3;

for i=1:(numel(A)-rows+1)
    B(1:rows,i)=A(i:i+rows-1,1);
end

Can someone help me do the same in a simpler way? I am guessing there is a one-line command that can solve that (maybe I'm wrong).

1 Answers
Related