MATLAB Answers

Conversion of MATLAB file to Simulink Block

71 views (last 30 days)
JOB
JOB on 2 Jun 2019
Commented: JOB on 3 Jun 2019
Hi,
I am new to Simulink, but I do code in MATLAB a lot. How can I convert my *.m file to Simulink. When the main m file (script) is executed around 3 files are loaded and values are assigned to variables, one or two user defined functions are also called and output is assigned to a variable. Please let me know how this can be made into a Simulink block.

  0 Comments

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 2 Jun 2019
There is no tool provided to convert .m into Simulink .
What you can do is use a MATLAB Function Block in simulink, and have that block call your code.
You will probably have to rewrite the code a bit. Anywhere that you have a call such as
result = outerFunction(InnerFunction(inputs))
you will typically need to rewrite that like,
temporary_result = zeros(expected_size_of_inner);
result = zeros(expected_size_of_outer);
temporary_result = InnerFunction(inputs);
result = outerFunction(temporary_result);

  1 Comment

Sign in to comment.

More Answers (0)

Sign in to answer this question.


Translated by