필터 지우기
필터 지우기

Why can't I use a bus with an array subelement?

조회 수: 3 (최근 30일)
Joe
Joe 2017년 9월 27일
댓글: Pierre Bélissent 2018년 10월 12일
Hello,
I've created a structure 'myStruct' and an associated bus called 'myStruct_Bus' successfully, however, when I try to use 'myStruct' as a constant on a Simulink Diagram after having set the data type to 'Bus: myStruct_Bus' I get the error "Invalid setting in... for parameter 'Value'". It's a legitimate struct and a legitimate Bus. Why the error?
(NOTE: I'm using 32-bit Matlab/Simulink R2015a on Windows 7 Professional 64-bit with Service Pack 1)
Here's the code:
myStruct = struct;
myStruct.aa = 0;
myStruct.bb = 0;
myStruct.cc = 0;
myStruct.sub = struct;
myStruct.sub(1).a = 0;
myStruct.sub(1).b = 0;
myStruct.sub(1).c = 0;
myStruct.sub(2).a = 0;
myStruct.sub(2).b = 0;
myStruct.sub(2).c = 0;
myStruct.sub(3).a = 0;
myStruct.sub(3).b = 0;
myStruct.sub(3).c = 0;
if ~exist('pSysParams_Bus')
busInfo_myStruct = Simulink.Bus.createObject(myStruct);
% get root Bus
tmp = who('slBus*');
for i=1:length(tmp)
if isempty(strfind(tmp{i}, '_'))
break;
end
end
myStruct_Bus = eval(tmp{i}); clear(tmp{i});
end
Notice that the Bus Editor confirms the array size of 3.

답변 (2개)

Suze Zhang
Suze Zhang 2017년 10월 9일
Hi Joe,
As of Simulink 8.1 (R2013a), it is possible to create a Simulink bus in which one of its fields is an array of buses. However, it is not available in Simulink R2015a to initialize a Simulink bus that contains a field which is an array of buses. As a workaround, you can create the buses separately, concatenate them using the Vector Concatenate block, and then include the array of buses in larger bus.
I have attached a zipped folder 'example.zip' for this workaround. The model 'sub_bus_example.slx' uses the Simulink.Bus objects that are defined in the 'busInfo.mat' file, and the 'makeStruct.m' script shows how to make these Simulink.Bus objects. Note that you can nest this structure further.
Suze
  댓글 수: 1
Pierre Bélissent
Pierre Bélissent 2018년 10월 12일
Thanks! Having the same issue. Is this capability (array of bus as a bus sub-element) available in newer versions?

댓글을 달려면 로그인하십시오.


Joe
Joe 2017년 10월 10일
Thanks Suze. I'll take a look. Is this capability available in newer versions?

카테고리

Help CenterFile Exchange에서 Composite Interfaces에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by