Nested buses in base workspace
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm trying to define a nested bus structure in the base workspace of MatLab. However, I'm not sure how I should actually write the code for it. Here is my attempt.
% names={'Ep_struct_Ex000_struct'}; %Define names of signals in this bus element
clear elems;
clear numElems;
for i=1
elems(i) = Simulink.StructElement;
elems(i).Name = char(names(i));
elems(i).Dimensions = 1;
elems(i).DataType = 'double';
elems(i).SampleTime = -1;
elems(i).Complexity = 'real';
elems(i).SamplingMode = 'Sample based';
names1={'Ex000_enum'...
,'E1000_DEF'...
,'E3000_DEF'...
,'E10k30A_DEF'...
,'E10k40A_DEF'...
,'E10k50A_DEF'...
,'E10kRot135degFS_DEF'...
,'E10kRot16turnFS_DEF'}; %Define names of signals in this bus element
clear elems1;
clear numElems1;
numElems1 = length(names1)
for i=1:numElems1
elems1(i) = Simulink.BusElement;
elems1(i).Name = char(names1(i));
elems1(i).Dimensions = 1;
elems1(i).DataType = 'double';
elems1(i).SampleTime = -1;
elems1(i).Complexity = 'real';
elems1(i).SamplingMode = 'Sample based';
end
elems(1)=Simulink.StructElement;
elems(1).Elements=elems1;
end
Ep_struct=Simulink.Bus; %Define bus
Ep_struct.Elements=elems; %Define whats in this bus
This code is meant to produce a Bus, Ep_struct which contains one elementEp_struct_Ex000_struct which itself is a bus which contains the elements, Ex000_enum...................E10kTor16turnFS_DEF.
The real structure I am trying to code is a lot more complicated than this but if I work out how to program 1 nested bus I should be able to do as many as I need.
So what is wrong with my code?
0 Kommentare
Antworten (1)
Kaustubha Govind
am 10 Aug. 2012
Bearbeitet: Kaustubha Govind
am 10 Aug. 2012
I think you just need to make the DataType field of the element that is another bus equal to something like 'Bus: elementEp_struct_Ex000_struct'. For example, a simpler version:
bus1 = Simulink.Bus;
el11 = Simulink.BusElement;
el11.Name = 'myel11';
el12 = Simulink.BusElement;
el12.Name = 'myel12';
bus1.Elements = [el11 el12];
bus2 = Simulink.Bus;
el21 = Simulink.BusElement;
el21.Name = 'myel21';
el21.DataType = 'Bus: bus1';
el22 = Simulink.BusElement;
el22.Name = 'myel22';
bus2.Elements = [el21 el22];
The resultant structure should be:
struct bus1 {
double myel11;
double myel12;
};
struct bus2 {
bus1 myel21;
double myel22;
};
0 Kommentare
Siehe auch
Kategorien
Mehr zu Composite Interfaces finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!