Python 在Simulink模型(MATLAB函数)中使用Shell Escape(!)
我试图在Simulink中使用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
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'),但除此之外,它工作得非常好。