MATLAB: Rewriting a loop construct

loop constructs

Just a thought guys, how would you rewrite this loop construct?
if i < 4
subplot(4,1,i+1);
plot(x,y);
title('Original');
end
I did try to write it as follows but something went wrong outside the loop:
subplot(4,1,i+1);
plot(x,y);
title('Original');
if i==2
break
end
What do you think of other loop constructs?

Best Answer

if you want to plot for i=1 to i=4,
for i=1:4
subplot(4,1,i+1);
plot(x,y);
title('Original');
end