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!

 Accepted Answer

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 Comments

That is what I was looking for. Thank you!
i have the same proplem but i need it to run the simulink in for llop from m file

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!