Array of structures in Simulink

5 vues (au cours des 30 derniers jours)
Pär
Pär le 6 Oct 2011
Hi!
I'm trying to develop a Simulink model that will iterate over a number of elements in an array of structures, where it will let the same operation be performed on each of those elements. E.g: Let say that we have the array of structure "A", consisting of A(n).Name A(n).Parents A(n).Children where "n" is some integer from 1 to N. Suppose that I wish to perform the operation on each of these 1 to N, elemets, e.g. some very simple as: A(n).Name ~= A(n).Parents;
To perform this I wish to use A as a constant which shall be fed the system. Further on, the appropiate subsystem "For Iterator", can be used to iterate over the different elements in A. Thus, I've created a "Matlab function", selecting elements from A with the iterating index from the subsystem "For iterator". Hence, the output from the "Matlab function" is: A(iteration-index).Name A(iteration-index).Parents A(iteration-index).Children The signal is pushed through to a new subsystem in Simulink where the operation is performed. Since the output from the "Matlab function", is a struct, I've defined a bus-object of the same type.
However I'm not able to send the first signal A since it is an array of structs as a signal into the "For iterator" subsystem, thus I can´t select the elements in the "Matlab function". I've managed to perform the iteration, if I let A be A(1) and define that signal with a bus object. But how can I define a bus object to fit an array of structs?
Thank you!
Any help is much appreciated.
  2 commentaires
Kaustubha Govind
Kaustubha Govind le 6 Oct 2011
An array of buses essentially still has the same datatype as the bus object, but dimensions>1; so I would expect that you can continue to use the same bus object to define the datatype of the array of buses.
What error do you get when attempting to use "A" with the For Iterator subsystem?
Pär
Pär le 7 Oct 2011
Thank you for your comment!
I get the eror message:
"Invalid setting in "MODEL/Constant" for parameter 'Value'".
Thus, if I try to feed the "For iterator" system with the constant "A2 specified as a bus object, I get the same error message.
Thank you!

Connectez-vous pour commenter.

Réponse acceptée

Pär
Pär le 17 Oct 2011
I managed to solve this by putting the functionality of this in a s-function, whom calls an external c-function.
Thank you for your help!

Plus de réponses (0)

Catégories

En savoir plus sur Subsystems dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by