MATLAB: How can i create figures in a for loop

for looploopplotplotting

I have to create a figure every 80 measurements of a row vector with length 31999 (Bn in the code). I tried to write this code but i receive only one figure with all the measurements (31999):
k= length(Bn);
for i= 1:80:(k-1)
Bn1(i) = L(i);
plot(Bn1);
end
any suggestion?

Best Answer

Try this:
repts = fix(numel(Bn)/80);
for k1 = 1:repts
figure(k1)
idxrng = (1:80) + 80*(k1-1);
plot(Bn(idxrng), L(idxrng))
grid
end