How can I call external m files as a block in simulink?

22 ビュー (過去 30 日間)
Sam Wallace
Sam Wallace 2015 年 6 月 20 日
コメント済み: Luffy 2015 年 6 月 20 日
I have a Simulink file which requires some output from another file not in the simulation which inputs from several other files. I can't use embedded MATLAB function as that wouldn't allow the other libraries I need to work. How can one run an external file, and take the output from it as if it were a block? If that is not possible, how could I put these external functions and data into the simulation? Thank you.

回答 (2 件)

Luffy
Luffy 2015 年 6 月 20 日
編集済み: Luffy 2015 年 6 月 20 日
I couldn't understand why you couldn't use the Matlab function block.
Otherwise,run the external m files & capture the outputs of those files into your base workspace & from there you could pass them to your Simulink model by using Input Ports.
To avoid doing this everytime,you can do the following: You can do this using a callback:
1) Open your Simulink model
2) Click "File" -> "Model Properties"
3) Select the second tab, called "Callbacks" in the "Model Properties" window that opened up
4) Select the right callback, and type in the name of your MATLAB function.
You probably can use "PreLoadFcn" callback. The in the "Model pre-load function:" part of the window, type your function, i.e., type loaddata if your function is loaddata.m.
  2 件のコメント
Sam Wallace
Sam Wallace 2015 年 6 月 20 日
What I would like to do is to call this external function repeatedly as part of a loop in the simulation. It doesn't seem like this has that functionality.
Luffy
Luffy 2015 年 6 月 20 日
Did you use Matlab function block ?Why was it not working ? If you use that,then you can repeatedly call the function

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


Azzi Abdelmalek
Azzi Abdelmalek 2015 年 6 月 20 日
You can use this block Interpreted Matlab Function formerly called Matlab Function

カテゴリ

Help Center および File ExchangeProgrammatic Model Editing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by