How to use a Matlab script in a Simulink Matlab Function Block, that is calling Matlab Functions.

16 ビュー (過去 30 日間)
Florian R.
Florian R. 2020 年 3 月 23 日
編集済み: Fangjun Jiang 2020 年 3 月 23 日
I hope, that i somehow can make clear what my problem is:
I do have a Simulink Model. Within this model I wan't to create a Matlab Function Block. The Matlab script, that I want to insert into the Matlab Function Block is already existing. This existing script is calling 9 different Matlab functions, that I need for computing my problem.
How do i make this work? I have to make keep the Matlab "script" and the called "functions" separate, otherwise my script would get way to big.

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2020 年 3 月 23 日
編集済み: Fangjun Jiang 2020 年 3 月 23 日
You can certainly do that. Just figure out the input/output of your script and make it the top-level function of your MATLAB Function block. In this simple example, you can call abs() which is a MATLAB function. You can also call MyOtherFun() which is your own function, saved in MyOtherFun.m file.
function y = fcn(u)
y =MyOtherFun(u);
y= abs(y);

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by