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

5 visualizzazioni (ultimi 30 giorni)
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.

Risposte (1)

Fangjun Jiang
Fangjun Jiang il 23 Mar 2020
Modificato: Fangjun Jiang il 23 Mar 2020
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);

Categorie

Scopri di più su Simulink Functions in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by