Error using structure in Simulink "propagated signal hierarchy is inconsistent with the bus object"
13 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Pramil
on 18 Sep 2024
Edited: Pramil
on 18 Sep 2024
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_test” to do the same and attached it for your reference. Before running the model just define "u = 3" in base workspace.
Hope it helps.
0 Comments
See Also
Categories
Find more on Sources in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!