Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

MATLAB Programming - Loop Control Part 2


In this lecture we will discuss more about Loop control.

- Switch – case commands

- Nested lops

- break command

- continue command

switch - case Command

There is no conditional statement used in this looping structure. It choose the code to be executed based on value of scalar or string, not just true/false. Different codes can be executed based on the value of the scalar defined in the switch command. The codes are defined using the case command.

Nested Loop

A nested Loop is a loop or conditional statement placed inside another loop or conditional statement. Simply, a loop within a loop. Both for and while loops can be nested.

break Statement

The break statement terminates execution of for or while loop. Statements in the loop that appear after the break statement are not executed. In nested loops, break exits only from the loop in which it occurs. Control passes to the statement following the end of that loop.



continue Statement


The continue statement is used for passing control to next iteration of for or while loop. The continue statement in MATLAB works somewhat like the break statement. Instead of forcing termination, however, 'continue' forces the next iteration of the loop to take place, skipping any code in between.


MATLAB Programming - Loop Control Part 2 from Shameer Ahmed Koya



This post first appeared on Electrical Engineering Tutorial, please read the originial post: here

Share the post

MATLAB Programming - Loop Control Part 2

×

Subscribe to Electrical Engineering Tutorial

Get updates delivered right to your inbox!

Thank you for your subscription

×