When you open a saved MuPAD® notebook file, the notebook displays the results (outputs), but the engine does not "remember" them. For example, suppose you saved the notebook myFile1.mn in your current folder and then opened it:
nb = mupad('myFile1.mn');
Suppose that myFile1.mn performs these computations.
Open that file and try to use the value w without synchronizing the notebook with its engine. The variable w currently has no assigned value.
To synchronize a MuPAD notebook with its engine, you must evaluate the notebook as follows:
Open the notebooks that you want to evaluate. Symbolic Math Toolbox™ cannot evaluate MuPAD notebooks without opening them.
Use evaluateMuPADNotebook. Alternatively, you can evaluate the notebook by selecting Notebook > Evaluate All from the main menu of the MuPAD notebook.
Perform your computations using data and results obtained from MuPAD notebooks.
Close the notebooks. This step is optional.
For example, evaluate the notebook myFile1.mn located in your current folder:
Now, you can use the data and results from that notebook in your computations. For example, copy the variables y and w to the MATLAB® workspace:
y = getVar(nb,'y') w = getVar(nb,'w')
y = sin(x)/(sin(x)^2 + 1) w = sin(x)/(sin(x)^2 - sin(x) + 1)
You can evaluate several notebooks in a single call by passing a vector of notebook handles to evaluateMuPADNotebook:
nb1 = mupad('myFile1.mn'); nb2 = mupad('myFile2.mn'); evaluateMuPADNotebook([nb1,nb2])
Also, you can use allMuPADNotebooks that returns handles to all currently open notebooks. For example, if you want to evaluate the notebooks with the handles nb1 and nb2, and no other notebooks are currently open, then enter:
If any calculation in a notebook throws an error, then evaluateMuPADNotebook stops. The error messages appear in the MATLAB Command Window and in the MuPAD notebook. When you evaluate several notebooks and one of them throws an error, evaluateMuPADNotebook does not proceed to the next notebook. It stops and displays an error message immediately. If you want to skip calculations that cause errors and evaluate all input regions that run without errors, use 'IgnoreErrors',true: