pyrun
Description
pyrun(
executes the Python® statements in code
)code
in the Python interpreter.
Variables created using the pyrun
function are persistent. You can
use these variables in subsequent calls to pyrun
.
executes the code with assigned input and output variable names using the MATLAB data passed by one or more name-value arguments.outvars
= pyrun(code
,outputs
,pyName=pyValue
)
Examples
Input Arguments
Output Arguments
Limitations
Python classes defined using
pyrun
orpyrunfile
cannot be modified if you return an instance of the class to MATLAB. If you need to change class definitions, restart the interpreter session:terminate(pyenv) pyenv(ExecutionMode="OutOfProcess")
Alternatively, restart MATLAB for
"InProcess"
.The
pyrun
andpyrunfile
functions do not support classes with local variables that are initialized by other local variables through methods. For such usage, create a module and access it using thepy.
prefix.
Version History
Introduced in R2021b