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

87 次查看(过去 30 天)
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 个评论
Michael Girbino
Michael Girbino 2018-10-12
编辑:Michael Girbino 2018-10-12
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);

请先登录,再进行评论。

采纳的回答

Michael Girbino
Michael Girbino 2018-10-12
Answer is in the comments.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by