How to pass a struct to a model reference instance?
Afficher commentaires plus anciens
Hi all,
I have a Simulink Parameter containing a struct that I would like to pass on to a model reference instance.
Using the parameter from the basae workspace is no problem, but I need to use different parameters for the individual instances.
My idea was to use the instance parameters, but it seems like I cannot use a struct there.

Data type "auto" is not allowed and struct is not available.
The parameters I'd like to pass on look like this:

Is there a way to use a struct as instance parameter?
Or is there maybe a totally different approach?
Any help would be highly appreciated. :)
Thanks!
Christopher
Réponse acceptée
Plus de réponses (1)
madhan ravi
le 23 Nov 2023
Modifié(e) : madhan ravi
le 23 Nov 2023
0 votes
elems(1) = Simulink.BusElement;
elems(1).Name = 'Chirp';
elems(2) = Simulink.BusElement;
elems(2).Name = 'Sine';
Sinusoidal = Simulink.Bus;
Sinusoidal.Elements = elems;
Sinusoidal1 = Simulink.Bus.createMATLABStruct('Sinusoidal'); % structure must be a Bus datatype
%Set the values for the parameter Sinusoidal1.Chirp = 0; Sinusoidal1.Sine = 1;
myParameter = Simulink.Parameter(Sinusoidal1) % pass the parameter values to the parameter object myParameter.DataType = 'Bus: Sinusoidal'

1 commentaire
Christopher Fromme
le 24 Nov 2023
Catégories
En savoir plus sur Component-Based Modeling dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!