Use struct to set symbolic dimension of Simulink bus element
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello,
I am trying to use a struct available in my model's data dictionary to symbolically set the dimension of a bus element. Below are the lines of code I am using
myBusElements(1) = Simulink.BusElement;
myBusElements(1).Name = 'myElement';
myBusElements(1).Dimensions = 'myDataDictionaryObject.myBusElementSize';
myBus = Simulink.Bus;
myBus.Elements = myBusElements;
Here is the error message I get
The 'Dot' operation is not supported as part of a symbolic dimension.
'myDataDictionaryObject.myBusElementSize'
^ To disable symbolic dimension propagation, clear 'Allow symbolic dimension specification' parameter in
the Configuration Parameters dialog box.
Any way to work around this? using a struct is a rigid requirement that I cannot ignore unfortunately as the struct in the data dictionary can change between model build and model run
Thanks!
0 Commenti
Risposte (1)
Ishu
il 3 Apr 2024
Hi Khushal,
I understand that you are trying to set the "Dimensions" property of "Simulink.BusElement" as a variable. You can use this method to set the parameters of other blocks like "Constant", "Gain" but this method is not supported for "Simulink.BusElement" that's why you are getting error.
To set "Dimesnions" you can follow below approach:
% ddPath - Path to your dictionary
dd = Simulink.data.dictionary.open(ddPath); %Open your dictionary
ddSection = getSection(dd, 'Design Data');
ddEntry = getEntry(ddSection, 'myDataDictionaryObject');
myStruct = getValue(ddEntry) % get the struct
myBusElementSize = myStruct.myBusElementSize; % get the dimension for bus element
myBusElements(1).Dimensions = myBusElementsize; %set the dimension
For more information on "Simulink.BusElement" you can refer below documentation:
Hope it helps!
0 Commenti
Vedere anche
Categorie
Scopri di più su Simulink Functions in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!