Clear Filters
Clear Filters

Use struct to set symbolic dimension of Simulink bus element

3 views (last 30 days)
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!

Answers (1)

Ishu
Ishu on 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!

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!