How to output an array as the output of an sfunction?

조회 수: 4 (최근 30일)
Shyam
Shyam 2013년 4월 19일
this is part of my code inside sfunctions:
#define OUTPUT_MIP(value) y[6] = (value)
#define OUTPUT_MAS(value) y[7] = (value)
Output of sfunction block is one wire (vector or array of all outputs)...so i put a demux and seperate them into individual variables...
what i want is to combine the 6th and 7th variable into an array variable, say y[6] and see both of them together in one wire after demux stage at the output of the sfunction block...
hope its clear...pls post ur suggestions...thanks

채택된 답변

Kaustubha Govind
Kaustubha Govind 2013년 4월 19일
You should just need to configure your S-function so that the numbers of output signals is 2, instead of 1, and set the output size of port#2 as 2. Then, refer to the second output port to assign values to it. I would recommend looking at some S-function demos to get started on this. Please run "sfundemos" at the MATLAB prompt to see examples of S-functions.
  댓글 수: 2
Shyam
Shyam 2013년 4월 20일
thanks.. its like u keep on outputting y[1]=... y[2]=... y[3]=... ........
depending on number of output ports and and size of each port, u either see it as a vector or a single value..
Kaustubha Govind
Kaustubha Govind 2013년 4월 22일
Shyam: Yes, but you also need to tell Simulink exactly how many ports the S-function has and the size of each signal.

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

추가 답변 (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