Use the code written in PYTHON in MATLAB/Simulink R2015b
4 ビュー (過去 30 日間)
古いコメントを表示
I am using MATLAB/Simulink version R2015b. Is it possible to incorporate and use code written in Python in a model of MATLAB/Simulink version R2015b? What kind of methods should I do?
0 件のコメント
回答 (2 件)
atharva
2023 年 12 月 7 日
Hey 猛,
I understand that you want to know how to incorporate and use code written in Python in a model of MATLAB/Simulink version R2015b
You can run a Python script from MATLAB using the "system" function. For example, if your Python script was named "file.py", you could run it from MATLAB using the following command:
>> system('python file.py')
However, running a Python script from Simulink is not officially supported. MATLAB code can be executed by a Simulink model, but this typically requires the MATLAB code to be supported for code generation, even if you are just simulating the Simulink model. The "system" function is not supported for code generation.
The best potential workaround would be to write a MATLAB function that uses the "system" command, and then use an Interpreted MATLAB Function block to run this MATLAB function in your Simulink model. If this method works, you will not be able to generate code for your model, and the model will likely simulate very slowly. If this method does not work, the best workaround would be to implement the functionality of your Simulink model in MATLAB instead of Simulink, since MATLAB does officially integrate with Python scripts.
You can look at the following documentation to have a better idea-
I hope this helps!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Call Python from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!