I found the documentation of function call in s-function level-2 for C/C++ BUT NOT for MATLAB. I am looking for explanation to do function call in .m instead of .c
Possible to call subfunction in S-function level-2
5 次查看(过去 30 天)
显示 更早的评论
I have been trying to convert my level-1 S-function to level-2 but I got stuck at calling another subfunction at function Output(block) trying to look for other threads but to no avail, do you mind to provide related links?
My output depends on a lot processing with the inputs, this is the reason I need to call the sub-function in order to calculate and then return output values, all the examples that I can see are calculating their outputs directly in "function Output(block)", in my case I thought it is not possible.
I then tried to use Interpreted Matlab Function block but failed due to the output dimension is NOT the same as input dimension, also it does not support the return of more than ONE output................
3 个评论
Kaustubha Govind
2013-7-17
编辑:Kaustubha Govind
2013-7-17
Please be specific about what your question is. You have multiple questions in your post. What does Function-Call Subsystems have to do with converting your S-function to Level-2?
采纳的回答
Kaustubha Govind
2013-7-17
MATLAB S-functions follow basic programming language rules of MATLAB, so you can certainly call into your external/sub-function to compute the outputs. Just assign the values to some temporary variables. For example:
function Output(block)
[t1, t2, t3] = myhelperfunction(block.InputPort(1).Data, ...
block.InputPort(2).Data);
block.OutputPort(1).Data = t1;
block.OutputPort(2).Data = t2;
block.OutputPort(3).Data = t3;
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!