Borrar filtros
Borrar filtros

Can I have a bus whose elements are buses with several dimensions?

4 visualizaciones (últimos 30 días)
Hi there,
I got a header file which is something like:
struct RPO_corners
{
float cod[3];
float orient[9];
float rotVel;
float defl;
float factor;
float TTTT;
};
struct Output
{
struct Vector3 coord,
speed,
accel,
angspeed;
struct Matrix3x3 orientation_matrix;
float value;
float value2;
float value3;
float value4;
int value5;
int value6;
struct RPO_corners corners[4];
};
typedef struct Output Output_T;
typedef struct RPO_corners RPO_corners_T;
The structure Ouput is sent to a c++ app. Therefore I need to create a bus(Ouput) which contains another bus (corners[4]). I have tried to concatenate the 4 corners buses with little success. The fact that "corners" is a vector of a struct is my problem.
When I define Output_T in the bus editor, I'm assuming that I need to specify 4 dimensions for the RP0_corners bus, rite? How can I implement that in Simulink?
Thanks in advance

Respuesta aceptada

TAB
TAB el 4 de Dic. de 2012
Editada: TAB el 4 de Dic. de 2012
To create the structure in c code you need to create non-virtual bus.
You can create 4 the non-virtual buses (RPO_corners) with the same bus object and concatenate then into an array of bus. This will create a array of structure in resulting code. You can again feed this array to another bus creator (again non-virtual) with other signals to creator to create final structure. In the Bus-Object of final bus set the size of element which is receiving bus array to 4.
See a simple example below
For more information on how create array of buses see Combine Buses into an Array of Buses.

Más respuestas (2)

Ryan G
Ryan G el 3 de Dic. de 2012
A bus of busses it possible, you can try it manually using Simulink to verify yourself. It sounds like you have a bus, Output, that contains a number of values, a Vector 3 bus, a Matrix3x3 bus and a RPO_corners bus. At least that's how I would define it for Simulink purposes here.
I believe you want to nest bus definitions. Have you tried that? If so, what are the issues?
  1 comentario
Jose Martinez
Jose Martinez el 4 de Dic. de 2012
thanks Ryan for the quick reply. I think the problem is that I need to use an array of C structs and I don't know how to construct the buses in Simulink. I don't have problems with vectors ( Vector3 or Matrix3x3 which in my case is a vector of 9 values). If the bus corners was a corners[1] rather than corners[4]. There won't be any problem.

Iniciar sesión para comentar.


Jose Martinez
Jose Martinez el 4 de Dic. de 2012
Btw the error I get is something like:
Bus element 'corners' of bus object 'Output_T' is a bus, but the incoming signal is not a bus.
'Corners' is defined as bus in the bus editor with dimension 4. I was wondering if that is right.

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by