How to generate .m file from SIMULINK model (.mdl file)?

56 ビュー (過去 30 日間)
Harish Balaga
Harish Balaga 2011 年 6 月 29 日
コメント済み: Walter Roberson 2018 年 6 月 8 日
hi, i have to use a simulink model and a matlab program for my project. but i need to switch between those to continuously and automatically. (without human intervention.).
so, as it is not possible, i want to generate .m file from simulink model, which can exactly replace the .mdl file output so that, i can include that program in my actual program. the viceversa is also acceptable.

回答 (3 件)

Andreas Goser
Andreas Goser 2011 年 6 月 29 日
In case you are at the beginning of your project, you could try to work MATLAB based and include the (same) code within Simulink, e.g. using Embedded MATLAB.
I you have a Simulink model, I do not know if there is a way to bring the model into MATLAB code, but you could always obtain the results in MATLAB bei using the SIM command.

Arnaud Miege
Arnaud Miege 2011 年 7 月 4 日
As Andreas suggested, use the sim command to run a Simulink model from MATLAB. There are a lot of other functions that allow you to interact with Simulink from MATLAB.
HTH,
Arnaud

Destiny Chukwuma
Destiny Chukwuma 2018 年 3 月 15 日
Please I have the same challenge. Can someone assist with specific steps to attempt concoverting block models to .m file so that other programs can be integrated onto it. Thanks
  4 件のコメント
Jun W
Jun W 2018 年 6 月 8 日
how to convert simulink model to matlab code manually? link? tutorial?
Walter Roberson
Walter Roberson 2018 年 6 月 8 日
You would need to understand what all of the blocks do. Some blocks need multiple MATLAB calls.
Also, Simulink is responsible for making sure that all signal values are mathematically self-consistent under the assumption that all feedback is happening simultaneously with the original signal unless there is a deliberate delay block programmed in. You would need to do those calculations yourself.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSimulink Coder についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by