MATLAB: How to create a 3-D array using information from FOR loop

3-d arrayfor loop

Hi there, I am currently having a problem with trying to get data out from a FOR loop and place into a 3-D array.
I have tried using Array3D= cat(3,A) within and outwith the FOR loop but cant seem to get the array to work.
Thanks

Best Answer

1. Predeclare the array, 2. Just assign to it using indexing instead of using concatenation that is going to be slow.
Array3D = zeros(1024, 1280, Images); %3D array of 2D images
for i = t:Images
%read frame, I've not dealt with Davis images for a while but wasn't it
%Img = B.Data ?
Array3D(:, :, i) = Img;
end