Problem with matrix in a Simulink bus.

9 views
Skip to first unread message

Alessandro

unread,
Apr 14, 2010, 5:44:26 AM4/14/10
to MATLAB Pool
Hello!
I have a problem. I have created a bus to be used in a simulink model
which contains a stateflow diagram.

elem = Simulink.BusElement;
elem.Name ='myMatrix';
elem.DataType = 'int32';
elem.Dimensions = [10 10];

newBus = Simulink.Bus;
newBus.HeaderFile = 'structure.h';
newBus.Name = 'myBus';
newBus.Elements = elem;
assignin('base', 'myBus', newBus);

I have specified a C header file: 'structure.h';

The structure.h is:

typedef struct {
int myMatrix[10][10];
} myBus;

When I start the simulation this error occurs:
Error c3_myModel.c: 202 operands of = have illegal types `array 10 of
int' and `int'
Error c3_myModel.c: 202 lvalue required

The error line is:

201. for (c3_i3 = 0; c3_i3 < 100; c3_i3 = c3_i3 + 1) {
202. chartInstance.c3_State.myMatrix[c3_i3] = 0;
203. }

Why does matlab try to initialize myMatrix as a vector, instead of as
a matrix?
I can see two solutions:
1) Set Matlab to not initialize myMatrix.
2) Set Matlab to see myMatrix as a matrix rather than a vector.

Can somebody help me?

Reply all
Reply to author
Forward
0 new messages