Filter löschen
Filter löschen

Why do I get the error "Invalid output port data type" in my Simulink model?

87 Ansichten (letzte 30 Tage)
When I try to run my Simulink model, I get the following errors in reference to a Stateflow block:
Invalid output port data type. Data type of output port 2 of 'regcontrol_model/RegControl' is invalid.
An error occurred while propagating data type 'uint8' through 'regcontrol_model/RegControl'.
I determined that the first error will occur on output 2 regardless of the order of my output ports.
I'm wondering why these errors occur, and are they related?
  3 Kommentare
TAB
TAB am 12 Okt. 2018
It would be nice if you can share your model or an example model.
Michael Girbino
Michael Girbino am 12 Okt. 2018
Bearbeitet: Michael Girbino am 12 Okt. 2018
In the process of removing my model's workspace dependencies so I can post the just the .slx file, I solved my problem.
I have a bus containing 32 constants whose values come from the MATLAB workspace:
In the definition of the bus object, my integer values are meant to be uint8:
TapLimitPerChange = Simulink.Parameter;
TapLimitPerChange.DataType = 'uint8';
TapLimitPerChange.Value = RCReg1.TapLimitPerChange;
EquipElems(5) = Simulink.BusElement;
EquipElems(5).Name = 'TapLimitPerChange';
EquipElems(5).Dimensions = 1;
EquipElems(5).DimensionsMode = 'Fixed';
EquipElems(5).DataType = 'uint8';
EquipElems(5).SampleTime = -1;
EquipElems(5).Complexity = 'real';
...But in the class definition used by the object RCReg1, the integers are typed as int32:
properties (PropertyType = 'int32 scalar')
TapLimitPerChange
end
This is why there was an error in data type propagation.
For reasons unknown to me, 'uint8 scalar' is not an acceptable PropertyType, so the solution is to typecast.
TapLimitPerChange.Value = uint8(RCReg1.TapLimitPerChange);

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Michael Girbino
Michael Girbino am 12 Okt. 2018
Answer is in the comments.

Weitere Antworten (0)

Kategorien

Mehr zu Simulink Functions finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by