setVar

Assign variable in MuPAD notebook

setvar(nb,MATLABvar) will be removed in a future release. Use the three argument version setvar(nb,'MuPADvar',MATLABexpr) instead.

Syntax

  • setVar(nb,MATLABvar)
  • setVar(nb,'MuPADvar',MATLABexpr) example

Description

setVar(nb,MATLABvar) copies the symbolic variable MATLABvar and its value in the MATLAB® workspace to the variable MATLABvar in the MuPAD® notebook nb.

example

setVar(nb,'MuPADvar',MATLABexpr) assigns the symbolic expression MATLABexpr in the MATLAB workspace to the variable MuPADvar in the MuPAD notebook nb.

Examples

expand all

Copy a Variable and Its Value from MATLAB to MuPAD

Copy a variable y with a value exp(-x) assigned to it from the MATLAB workspace to a MuPAD notebook. Do all three steps in the MATLAB Command Window.

Create the symbolic variable x and assign the expression exp(-x) to y:

syms x
y = exp(-x);

Create a new MuPAD notebook and specify a handle mpnb to that notebook:

mpnb = mupad;

Copy the variable y and its value exp(-x) to the MuPAD notebook mpnb:

setVar(mpnb,'y',y)

After executing this statement, the MuPAD engine associated with the mpnb notebook contains the variable y, with its value exp(-x).

Assign a MATLAB Symbolic Expression to a Variable in MuPAD

Working in the MATLAB Command Window, assign an expression t^2 + 1 to a variable g in a MuPAD notebook. Do all three steps in the MATLAB Command Window.

Create the symbolic variable t:

syms t

Create a new MuPAD notebook and specify a handle mpnb to that notebook:

mpnb = mupad;

Assign the value t^2 + 1 to the variable g in the MuPAD notebook mpnb:

setVar(mpnb,'g',t^2 + 1)

After executing this statement, the MuPAD engine associated with the mpnb notebook contains the variable g, with its value t^2 + 1.

Input Arguments

expand all

nb — Pointer to MuPAD notebookhandle to notebook | vector of handles to notebooks

Pointer to a MuPAD notebook, specified as a MuPAD notebook handle or a vector of handles. You create the notebook handle when opening a notebook with the mupad or openmn function.

MuPADvar — Variable in MuPAD notebookvariable

Variable in a MuPAD notebook, specified as a variable.

MATLABvar — Variable in MATLAB workspacesymbolic variable

Variable in the MATLAB workspace, specified as a symbolic variable.

MATLABexpr — Expression in MATLAB workspacesymbolic expression

Expression in the MATLAB workspace, specified as a symbolic expression.

See Also

| |

Was this topic helpful?