필터 지우기
필터 지우기

Using a Bus array inside of a Bus using cellToObject

조회 수: 4 (최근 30일)
Oyun
Oyun 2011년 3월 7일
Matlab version: 7.10.0.499 (R2010a) 32-bit
Hi,
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 '}}};'];
eval(str);
Simulink.Bus.cellToObject(subcell);
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 '}}};'];
eval(str);
Simulink.Bus.cellToObject(cell);
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

답변 (2개)

MarkB
MarkB 2011년 3월 7일
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
Oyun 2011년 3월 7일
Hi,
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

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by