Documentation Center

  • Trials
  • Product Updates

next, _next

Skip a step in a loop

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

next
_next()

Description

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.

Examples

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;
  print(i)
end_for:

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

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

delete i:

See Also

MuPAD Functions

Was this topic helpful?