MATLAB: How to count if loops

countcounterif looploopwhile loop

I have code that needs to count a loop.
while loopEnd<loopStart count=0 loopStart=1 loopEnd=6 while loopStart < loopEnd count = count + 1 loopStart = loopStart + 5

Best Answer

count=0
loopStart=1
loopEnd=6
while loopStart < loopEnd
count = count + 1
loopStart = loopStart + 5
end
It looks like count gets set to zero any time this part of the code executes. count should probably be initialized earlier in the code.
Related Question