Error using structure in Simulink "propagated signal hierarchy is inconsistent with the bus object"

44 次查看(过去 30 天)
I can't seem to implement a simple structure in Simulink. I've followed instructions in Matlab Documentation as best as I can, and gone thru many Q&A's in Matlab Answers forum, but no luck. Including this documentation: Attach Bus Signals to MATLAB Function Blocks .
I'm using R2015a.
The simulation error is as follows:
Error occurred while propagating bus signal hierarchy to input port 1 of the block
'struct_test/Bus Creator1'. The propagated signal hierarchy is inconsistent with the
bus object 'slBus1' specified on the block. This bus object directly or indirectly
has a bus element with data type 'double' that does not match the propagated signal
hierarchy.
Here's the Simulink model screenshot: A very simple model, but I plan to build on it for a much more complex analysis.
Code for Function 1:
function idx = fcn(u)
mystruct = struct('R',zeros(3));
idx = mystruct;
idx.R = rand(u+2);
Screenshot of Ports and Data Mgr for Function 1:
Screenshot of Bus Creator1 block properties:
Code for Function 2:
function y = fcn(idx_in)
idx_out = struct('R',zeros(3));
idx_out = idx_in;
y = sum(sum(idx_out.R)); % Sums all values of the 3x3 matrix.
Screenshot of Ports and Data Mgr for Function 2:
And finally the Bus Object used for the function blocks' structure data type.
Hope someone can help. Thanks in advance.
  3 个评论
MarkD
MarkD 2016-9-1
Swarooph, thanks for the response. Here's the SL model along with the script to load up the bus object 'slBus1' prior to running the model.

请先登录,再进行评论。

回答(1 个)

Pramil
Pramil 2024-9-18
编辑:Pramil 2024-9-18
Hey MarkD,
As the error suggests, the “Bus Creator” block expects a data of type “double, but it receives a data of type “Bus” from the “MATLAB Function” block.
If you change the datatype of “MATLAB Function” block “idx” to double” type and provide the “Bus Creator” block a “double 3X3” value, as defined in your “bus” element, it will resolve the issue.
I have updated your model “struct_testto do the same and attached it for your reference. Before running the model just define "u = 3" in base workspace.
Hope it helps.

产品

Community Treasure Hunt

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

Start Hunting!

Translated by