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.
The names of the built-in MuPAD® functions and options are protected. If you try to assign a value to a MuPAD function or option, the system throws an error. This approach ensures that you will not overwrite a built-in function or option accidentally.
If you create a new MuPAD procedure, it is recommended to protect the procedure and all its options, especially if you often use that procedure. For example, MuPAD does not provide a function for computing Lucas numbers. You can write your own procedure for computing Lucas numbers, and then protect the procedure name.
The Lucas numbers are a sequence of integers. The recursion
formula that defines the
nth Lucas number is similar
to the definition of the Fibonacci numbers:
Create the following procedure that computes the
lucas:= proc(n:Type::PosInt) option remember; begin if n = 1 then 1 elif n = 2 then 3 else lucas(n - 1) + lucas(n - 2) end_if end_proc: lucas(i) $ i = 1..5
Now protect the procedure name,
protect with the
ProtectLevelError lets you set full protection
for the identifier. Now, trying to assign any value to
lucas := 0
Error: Identifier 'lucas' is protected. [_assign]
Alternatively, you can use the
In this case, you can still assign a value to the protected identifier,
but a warning appears, for example:
You can assign any value to
lucas now, but
such assignment triggers a warning:
lucas := 0
Warning: Protected variable 'lucas' is overwritten. [_assign]
For further computations, remove protection from the identifier