pyrunfile
- : pyrunfile
(file)¶ - : pyrunfile
(file_input)¶ - :
outvars =pyrunfile(file, outputs)¶ - :
outvars =pyrunfile(file, outputs, pyName, pyValue, …)¶ Run a Python script file from Nexus (MATLAB R2026a
pyrunfileparity).pyrunfile (file)executes the Python statements in file. Variables created bypyrunfileare not persistent across calls.pyrunfile ("script.py 'arg'")passes command-line arguments that the script reads viasys.argv(same quoting rules as MATLAB).outvars = pyrunfile (file, outputs)returns named Python variables. outputs is a character vector, string array, or cellstr of names. Whennargoutexceeds the number of names, the error id isMATLAB:maxlhs.Name/value inputs use alternating pyName, pyValue pairs after outputs (MATLAB also accepts
Name=Value; Nexus call sites should use char/value pairs because name=value is stripped to the value alone).Output conversion matches MATLAB R2026a for the documented cases: Python
list->py.list,dict->py.dict,float-> double,bool-> logical,str->py.str(char-backed stub),int->py.int(numeric stub),None->py.NoneType,numpy.ndarray-> native numeric array (dtype preserved; 1-D becomes a row).Error ids match MATLAB:
MATLAB:minrhs,MATLAB:Pyrunfile:EmptyFilename,MATLAB:Pyrunfile:InvalidFilenameType,MATLAB:Pyrunfile:FileNotFound,MATLAB:Pyrun:InvalidOutputList,MATLAB:Python:PyException,MATLAB:maxlhs.