MATLAB: Index variable based on time points

forloopmri

i have a variable with 1400 images stored in it. I want to index this loop into 40 time points, (so there are 40 variables each containing 35 frames)
mri % 128 x 128 x 1400 uint16
I am trying to build a loop that for each instance in the loop (t = 40), 35 frames are stored into an output variable so essentially at the end I could have an output variable which is
output % 128 x 128 x 35 frames x 40 timepoints
%here is the rudimentary code that I am working from to build into a for loop
perf_0 = mri(:,:,1:35);
perf_1 = mri(:,:,36:70);
perf_2 = mri(:,:,71:105);
perf_3 = mri(:,:,106:140);
perf_4 = mri(:,:,141:175);
perf_5 = mri(:,:,176:210);
perf_6 = mri(:,:,211:245);

Best Answer

output = zeros(size(mri,1), size(mri,2), 35, 40, class(mri));
for t = 1 : 40
output(:,:,:,t) = mri(:,:,35*(t-1) + (1:35));
end
However if this was your purpose then just use
output = reshape(mri, size(mri,1), size(mri,2), 35, 40);