Your loop has 19 iterations. It is not clear, why you expect that the output has a size of 30 or 540 in the 3rd dimension.
[i:i] is the same as the much simpler: i .
A simplified version of your code:
No loop needed. But I do not see, how this could produce a size of 30 or 540.
By the way, this can be simplified also:
ST=NaN*ones(128,64,30)
ST = NaN(128, 64, 30)
But it is not useful here, so better omit it.
[EDITED] After the clarifications:
ST = NaN(128, 64, 18, 30);
ini = 30;
len = 18;
for k = 1:30
ST(:, :, :, k) = T(:, :, ini:ini + len - 1);
ini = ini + 72;
end
ST = reshape(ST, 128, 64, 540);
v = 1:72;
match = (30 <= v & v < 48);
ST = T(:, :, repmat(match, 1, 30));
Best Answer