フィルターのクリア

Call a Matlab function in Simulink from the current folder

63 ビュー (過去 30 日間)
Alberto Bolzoni
Alberto Bolzoni 2018 年 2 月 27 日
編集済み: lokender Rawat 2018 年 3 月 6 日
Good morning.
Is it possible to create in Simulink a block that calls a MATLAB function placed in the same folder? I know that it is possible to copy-paste the code in a MATLAB function block, but I would like the Simulink simulation to call directly the function file (e.g. "function.m") from the current folder of from the Simulink project. The function is multi-input thus I cannot use the "Interpret MATLAB function" block.
Thank you for any help
Alberto

回答 (1 件)

lokender Rawat
lokender Rawat 2018 年 3 月 6 日
編集済み: lokender Rawat 2018 年 3 月 6 日
There are numerous ways to call a function in Simulink block:
1. MATLAB function block - intend to generate code from your model.
2. Interpret MATLAB function block - if you don't care about code generation.
3. Fcn block - if you have trivial expression to evaluate.
4. Create a "function.m" file in the current directory and then according to the your requirement you can set the callbacks in the "File->Model properties->Callbacks".
Suppose, you want your function to get executed before the model runs, you can place the function name in the "InitFcn". There are other callbacks model as well to choose from.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by