Question
Can I have more than 1 output argument from a function that I use in the MATLAB Function block in Simulink? I have a user written function that has multiple input and output arguments. For example: [a,b,c,d] = my_function(x,y,z) But when I try to use this in the MATLAB FCN block in Simulink I get the following error: ??? Error using ==> sim Error in MATLAB Function block 'my_model/MATLAB Fcn' while computing the output. The width of the result was 1 when a width of 4 was expected. I have specified the number of outputs from the block as 4. But only one output from the function is seen.
Expert Answer
John Williams
PhD Expert
Answered Aug 14, 2026
I believe the link might be complicated for some people so I will suggest a simple solution from the R2021a version that I used to save people some time.
- On the MATLAB FCN block, if you hover over to the edges that input and outputs are located in, u can see a plus indicator. Once you click and hit enter, you can easily add inputs and outpus to the amount you desire.
- If you double click the block you can copy and paste your script to use in the SIMULINK model,
I am not that experienced in SIMULINK so if a more automated way is requiered, than you might find salvation in reading through the link above.
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related simulink Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →