Possible to call subfunction in S-function level-2

조회 수: 4 (최근 30일)
want2know
want2know 2013년 7월 17일
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
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?
want2know
want2know 2013년 7월 17일
Sorry for confusing, I have edited the question to be specific, thanks for your consideration.

댓글을 달려면 로그인하십시오.

채택된 답변

Kaustubha Govind
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;
  댓글 수: 1
want2know
want2know 2013년 7월 17일
Thanks Kaustubha for the details.
In the "myhelperfunction", should the program code follow what we normally write in .m file or does it need to have specific syntax?
Do you mind to provide me the links or resources or examples (demos) for details of sub-function used in S-function level-2?
Thank you so much, more than I can say.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by