S function builder for array of bus as output

조회 수: 3 (최근 30일)
sun P
sun P 2012년 10월 23일
답변: Voulgarakis Georgios 2014년 5월 27일
Hi, I am using S function builder, and I want my output to be a array of bus. Can any one tell how to declare output as an array of bus signal. Thank you.

채택된 답변

Sachin Ganjare
Sachin Ganjare 2012년 10월 23일
편집: Sachin Ganjare 2012년 10월 23일
Refer link below:
And refer section 'S-function Builder Bus Support'.
Hope it helps!!!
  댓글 수: 1
sun P
sun P 2012년 10월 23일
Thank you for the answer Sachin.
But I have seen this blog but in this no discussion about 'Array'. I need to declare bus signal as array.
Thank you.

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

추가 답변 (2개)

Kaustubha Govind
Kaustubha Govind 2012년 10월 23일
It doesn't look like the S-function Builder supports array of buses at this point. Note how the edit-fields to specify dimensions are immediately disabled when "Bus" is turned on. You could probably place the S-function Builder block inside a For Each subsystem or other similar options to iterate over each bus element and have the S-function deal with one bus at a time. If you need the S-function to process the whole array at the same time, you might need to first generate an S-function using an S-function Builder or Legacy Code Tool, and then manually modify it to handle an array of buses.
  댓글 수: 1
sun P
sun P 2012년 10월 24일
Thank You Kaustubha.
I think manual modification of S function will work for me.
Thank You.

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


Voulgarakis Georgios
Voulgarakis Georgios 2014년 5월 27일
I had the same problem (I wanted to use an array of buses in s-function builder which is not supported). The only way I see, to solve this, is to do the following trick:
1) Declare and use a *.c and *.h file. In the header you should define the BUS as a struct, and in the *.c file you should write the processing code. You should then include these files in the S-function builder, and call the main (entry) function declared in the *.c file. All handling of the BUS should be performed in the *.c file.
2) Declare the C struct, , with the following format:
struct BUS1{
...
BUS2 array[10];
...
}
3) Using the Bus editor, declare the BUS1 and BUS2 buses. And HERE IS THE TRICK: do not define array as of Dimensions 10, of type BUS2, BUT DECLARE 10 BUS2 ELEMENTS INSTEAD. I know it's not clean (and annoying if you need to handle large arrays), but until simulink starts supporting bus arrays, this is the only way I see.
I.E.
BUS1{
...
BUS2 array0;
BUS2 array1;
....
BUS2 array9;
...
}
In terms of memory, these 2 are the same, since the pointer of the array0 == pointer of array[0], etc...
Hope I helped....

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by