Can I have more than 1 output argument from a function that I use in the MATLAB Function block in Simulink?
33 ビュー (過去 30 日間)
古いコメントを表示
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.
採用された回答
MathWorks Support Team
2009 年 6 月 27 日
You cannot pass more than one (1) argument out of a function that is used in the MATLAB FCN block.
If you need to pass more than one variable out of a function, you will have to concatenate all variables into one vector, and pass that vector out of the function. In other words, the single output from the function will have to be a vector with all the values that you need passed out. You can then use a Demux Block to split the vector into its individual signals.
Alternatively, you may use the Embedded MATLAB Function block. This block can accept multiple inputs and return multiple outputs.
0 件のコメント
その他の回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!