It is my understanding that you are trying to combine all the looped-operations into a single loop.
You can combine the code into a single loop, by integrating the operations that depend on the loop index. Here, in the following implementation, I have implemented the same while optimizing redundant operations.
f=1;
N = 330;
M = nan(156,206,N);
b=load('timestamp.txt');
b(1)=0;
c=0;
for ii = 1:N
M = load(sprintf('frames_%d.txt',ii-1));
if(ii>1)
c = c + b(ii);
end
I(:,:,ii)=squeeze(M)'.*sin(2*pi*f.*c);
Q(:,:,ii)=squeeze(M)'.*cos(2*pi*f.*c);
end
II=sum(I,3);
QQ=sum(Q,3);
Amp=sqrt(II.^2+QQ.^2);dlk
figure; imagesc(Amp)
Additionally, you can also refer to the following resource to know more about loop-controls in MATLAB:
