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 endIt 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 SolutionsMATLAB: Finding elements in an array that differ by a certain tolerance from elements in another array of different size Read about ismembertol MATLAB: How to save the number of iterations in while loop Set up a counter variable.Example:count = 0;while -CONDITION- -DO CALCULATIONS- -UPDATE CONDITION VARIABLE- count = count + 1;end Related QuestionHow to use a while loop with an excel file
Best Answer