Is it possible to convert a Simulink Model into a Matlab function?

Hi everybody!
I am new to Matlab and Simulink and I wonder if it is possible to convert a Simulink Model into a Matlab function to be invoked in a .m script.
For example, my Simulink Model has got two imputs, A and B, and a output, U. Is it possible to generate the function
'myModel'
and then to use it, writing
U = myModel(A, B);
in my script?
Thank you very much!

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 3 月 29 日

0 投票

You can run your simulink model from any script by the command sim, for inputs and outputs, your simulink model can communicate with data from workspace (To workspace block), or from file (from file block) and export the result to workspace (To workspace block) or to a file (To file block).

3 件のコメント

Alessio Antolini
Alessio Antolini 2016 年 3 月 30 日
That is what I was looking for. Thank you!
Azzi Abdelmalek
Azzi Abdelmalek 2016 年 3 月 30 日
You may need set_param command
wissam alansari
wissam alansari 2023 年 9 月 10 日
i have the same proplem but i need it to run the simulink in for llop from m file

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeSimulink についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by