Shortcut for Closing Statements

MuPAD® notebooks will be removed in a future release. 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.

As a shortcut for a closing statement, use the end command. This command closes:

  • Conditional structures if ... then ... else (a shortcut for end_if)

  • Case Selection Structures case ... of (a shortcut for end_case)

  • Loops (a shortcut for end_for, end_repeat, and end_while)

  • Procedures (a shortcut for end_proc)

For example, the following two loops are equivalent:

for i in [0, 1, 0, 0] do
  if i = 1 then
    print(Unquoted, "True")
  else
    print(Unquoted, "False")
  end_if
end_for
False
True
False
False
for i in [0, 1, 0, 0] do
  if i = 1 then
    print(Unquoted, "True")
  else
    print(Unquoted, "False")
  end
end
False
True
False
False