This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

next, _next

Skip a step in a loop

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.




next interrupts the current step in for, repeat, and while loops. Execution proceeds with the next step of the loop.

The next statement is equivalent to the function call _next(). The return value is the void object of type DOM_NULL.

Inside for, repeat, and while loops, the next statement interrupts the current step of the loop. In for statements, the loop variable is incremented and execution continues at the beginning of the loop. Similarly, the control conditions at the beginning of a while loop and in the until clause of a repeat loop are verified, before execution continues at the beginning of the loop.

Outside for, repeat, and while loops, the next statement has no effect.


Example 1

In the following for loop, any step with even i is skipped:

for i from 1 to 5 do
  if testtype(i, Type::Even) then next end_if;

In the following repeat loop, all steps with odd i are skipped:

i := 0:
  i := i + 1;
  if testtype(i, Type::Odd) then next end_if;
until i >= 5 end_repeat:

delete i:

See Also

MuPAD Functions

Was this topic helpful?