MATLAB: “while” loop nested within “for” loop

for loopMATLABnestedwhile loop

I'm terribly sorry if this seems like a very basic question (i'm just beginning to learn MATLAB). Anyways, can someone please show me a simple example of a while loop nested within a for loop? I understand the two loops separately but I can't figure out how to apply them together.

Best Answer

N = 5;
for ii = 1:3
ii
M = ii + 1;
while M < N
M = M + 1
end
end