MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.
To convert a MuPAD notebook file to a MATLAB live script file, see
convertMuPADNotebook. MATLAB live scripts support most MuPAD functionality, although there are some differences. For more information, see
Convert MuPAD Notebooks to MATLAB Live Scripts.
Symbolic Math Toolbox™ lets you integrate symbolic computations into the Simscape™ modeling workflow by using the results of these computations in the Simscape equation section.
If you work in the MATLAB Live Editor, see Generate Simscape Equations from Symbolic Expressions. Working in the MATLAB Live Editor is recommended.
If you work in the MuPAD Notebook app, you can:
Assign the MuPAD expression to a variable, copy
that variable from a notebook to the MATLAB workspace, and use
generate the Simscape equation in the MATLAB Command Window.
Generate the Simscape equation from the MuPAD expression in a notebook.
In both cases, to use the generated equation, you must manually copy the equation and paste it to the equation section of the Simscape component file.
For example, follow these steps to generate a Simscape equation from the solution of the ordinary differential equation computed in the MuPAD Notebook app:
Open a MuPAD notebook with the handle
notebook_handle = mupad;
In this notebook, define the following equation:
s:= ode(y'(t) = y(t)^2, y(t)):
Decide whether you want to generate the Simscape equation in the MuPAD Notebook or in the MATLAB Command Window.
To generate the Simscape equation in the same notebook,
generate::Simscape. To display generated Simscape code
on screen, use the
This command returns the Simscape equation that you can copy and paste to the Simscape equation section:
-y^2+y.der == 0.0;
To generate the Simscape equation in the MATLAB Command Window, follow these steps:
getVar to copy variable
the MATLAB workspace:
s = getVar(notebook_handle, 's')
s and its value appear in the MATLAB workspace
and in the MATLAB Command Window:
s = ode(diff(y(t), t) - y(t)^2, y(t))
simscapeEquation to generate
the Simscape equation from
You can copy and paste the generated equation to the Simscape equation
section. Do not copy the automatically generated variable
the equal sign that follows it.
ans = s == (-y^2+y.der == 0.0);