Use struct to set symbolic dimension of Simulink bus element

9 vues (au cours des 30 derniers jours)
Khushal Ashok Bhatija
Khushal Ashok Bhatija le 26 Juil 2023
Réponse apportée : Ishu le 3 Avr 2024
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!

Réponses (1)

Ishu
Ishu le 3 Avr 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!

Catégories

En savoir plus sur Manage Design Data dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by