

The first one is nested for loop, and the other one is nested while loop. There are two types of nested loops in MATLAB. You can also use a loop inside another loop in Matlab. When the code above is executed, the result is: When the code above is executed, the result will be: ValArray - In this, the program creates a column vector index from subsequent columns of the array. And it decrements when the step is negative. Initval:step:endval - In this, the index increments by the value step on each iteration. Initval:endval - Here, you need to specify the index variable from initval to endval by 1.Īnd the statement executes until the index is greater than endval. Values: There can be following forms of value: In other words, the result contains the non zero elements or non-empty the condition becomes true, otherwise false.

In the while loop, the program statement repeatedly executes as long as the expression becomes false.

It executes the statement continuously until the specific condition becomes false. The while loop works on the simple phenomena.
