Using a Bus array inside of a Bus using cellToObject

2 views (last 30 days)
Oyun on 7 Mar 2011
Matlab version: (R2010a) 32-bit
I need to create a bus array inside of a bus using the function Simulink.Bus.cellToObject. Please review the following code:
str = 'subcell = {';
str = [str '{''SUBBUS'','''',sprintf(''''),{'];
str = [str '{''index'',1, ''double'', -1, ''real'', ''Sample'', ''Fixed''};'];
str = [str '{''value'',1, ''double'', -1, ''real'', ''Sample'', ''Fixed''};'];
str = [str '}}};'];
str = 'cell = {';
str = [str '{''BUS'','''',sprintf(''''),{'];
str = [str '{''a'',1, ''double'', -1, ''real'', ''Sample'', ''Fixed''};'];
str = [str '{''b'',5, ''SUBBUS'', -1, ''real'', ''Sample'', ''Fixed''};'];
str = [str '{''c'',1, ''double'', -1, ''real'', ''Sample'', ''Fixed''};'];
str = [str '}}};'];
The matlab code compiles. However, the dimension of the SUBBUS is somehow ignored. I know that arrays of buses were introduced with the 2010b version (i am using 2010a) as i found this in the web:
"Arrays of structures are not allowed in 10a. Structure parameters can be thought of as an analogue of bus signals, and arrays of buses are not currently allowed in Simulink."
Is there any other way to implement this in another fashion without updating to 2010b?
Best regards, Oyun Kwon

Answers (2)

MarkB on 7 Mar 2011
I don't believe that there is any real analogue to this in releases earlier than 2010b. The closest thing that you could do is make a bus instead of an array at the top level where that bus happens to be a bunch of identical sub-buses, but this lacks the ability to use numerical indexing that would be possible with an array at the top level.

Oyun on 7 Mar 2011
First of all, thanks for the quick answer. Yes, I also thought of that approach. The problem is that I will be feeding this Simulink.Bus object into a sfunction which requires the indexing.
Well, at the time being there are 2 options for me: 1. upgrade to 2010b 2. use a 2D array instead of a bus and modify the sfun C-source
I think I'll go for option 2.
Thanks again, Oyun Kwon

Community Treasure Hunt

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

Start Hunting!