Array of structures in Simulink

5 次查看(过去 30 天)
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 个评论
Kaustubha Govind
Kaustubha Govind 2011-10-6
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 2011-10-7
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!

请先登录,再进行评论。

采纳的回答

Pär
Pär 2011-10-17
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!

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Subsystems 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by