MATLAB Answers

Matrix input/output to a Matlab function block in simulink

133 views (last 30 days)
I need help creating a MATLAB function block in simulink. How do i make a MATLAB function block take in a large matrix from the workspace as its input (say a 1000 by 15 matrix), and also give its output as a matrix?

Sign in to comment.

Accepted Answer

Ameer Hamza
Ameer Hamza on 23 Oct 2020
An alternate way is to create a parameter input in the MATLAB function block and give it the same name as the base workspace variable. Refer to Kaustubha's answer here: and follow the instructions after "Besides TAB's solution, ...". Following link will also be helpful
A slight advantage is that you don't need to create an additional block in your model.

Sign in to comment.

More Answers (1)

Fangjun Jiang
Fangjun Jiang on 23 Oct 2020
Use a Constant block, specify the value as the variable in the base workspace, then you will be able to use it, no matter what is the size of the matrix. When you construct the code for the MATLAB Function block, click the "Edit Data" button and specify the size of input and output variable.

Community Treasure Hunt

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

Start Hunting!