Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在Simulink模型(MATLAB函数)中使用Shell Escape(!)_Python_Matlab - Fatal编程技术网

Python 在Simulink模型(MATLAB函数)中使用Shell Escape(!)

Python 在Simulink模型(MATLAB函数)中使用Shell Escape(!),python,matlab,Python,Matlab,我试图在Simulink中使用MATLAB函数,使用shell转义函数调用Python脚本 MATLAB函数文件(.m文件)中的唯一代码如下: function y = fcn(u) %#codegen !C:\Python27\python.exe C:\Users\Ben\Downloads\endrecording.py y = u; 当我尝试执行此代码时,收到以下错误: 不支持Shell转义(!) Function 'MATLAB Function' (#35.30.9

我试图在Simulink中使用
MATLAB
函数,使用shell转义函数调用
Python
脚本

MATLAB
函数文件(.m文件)中的唯一代码如下:

function y = fcn(u)    
%#codegen  
!C:\Python27\python.exe C:\Users\Ben\Downloads\endrecording.py  
y = u;
当我尝试执行此代码时,收到以下错误:

不支持Shell转义(!)

Function 'MATLAB Function' (#35.30.92), line 3, column 1:
"!C:\Python27\python.exe C:\Users\Ben\Downloads\endrecording.py"
Launch diagnostic report.
是否有其他方法可以调用此Python脚本而不使用Shell Escape,或者可能有一种解决方法来让Shell Escape正常工作?

请改用该函数

function y = fcn(u)    
%#codegen  
system('C:\Python27\python.exe C:\Users\Ben\Downloads\endrecording.py')
y = u;

也请阅读了解更多详细信息。

在最新版本的MATLAB中,可以直接调用python:非常感谢!最后,我不得不在函数的开头添加一行代码:coder.extrinsic('system'),但除此之外,它工作得非常好。