MATLAB: Obtain specific components of a matrix

for loopmatrix

Hello
I have a TKE_t matrix with dimensions 104*19000 , and I need to obtain values in the following order
1 14 27 40 53 66 79 92
2 15 28 41 54 67 80 93
3 16 29 42 55 68 81 94
……
13 26 39 52 65 78 91 104
ı can obtain the first one by following code:
TKE_d1=zeros(8,1);
for r=1:8
TKE_d1(r,:)=TKE_t(13*r-12,:);
end
and I can repeat the same code by changing 13*r -12 to 13*r-11 and so on to obtain other values but how I can write one code to do this ? I thought of a 2 varaible for-loop but ı couldnt make it work…

Best Answer

M = 8;
N = 13;
L = 19000;
TKE_d = reshape(permute(reshape(TKE_t,N,M,L),[2,1,3]),M*N,L);
where
TKE_t=transpose(TKE);
as you defined in your code. I defined those parameters because I was testing on smaller cases, and also to illustrate how it generalizes.