Posted By:
20 Mar, 2013 6:33 pm PDT

Write a for loop and a while loop with break in Matlab

How to write a loop in matlab which is executed 10 times

what is the difference between for and while loop?


You can either use for or while loop for this, the for loop:

>>for i = 1:10




While loop:

>>while i<10



Difference between the two is that for loop is executed fixed number of times, and while loop is infinitely number of times until the exit condition is defined Please watch video and attached matlab file for details.

Attachment: for_while_basic.m
Was it useful?  

Please login to reply to this problem.