Borrar filtros
Borrar filtros

Matlab model for Array of structure possible?

2 visualizaciones (últimos 30 días)
Renish Ramegowda
Renish Ramegowda el 13 de Dic. de 2013
Respondida: Renish Ramegowda el 20 de Dic. de 2013
Can anybody help me by guiding the way to model below piece of code? Its array of structure and I wrote class files for Enum and created Simulink.Bus & Simulink.BusElement to define the structure. Now I'm struck at creating the array of structure in modelling/stateflow. Please suggest.
typedef struct { uint16 str_mem1; int16 str_mem2; Enum_1 str_mem3; Enum_2 str_mem4; } strct_1;
typedef enum { Enum_mem_1 = 0 ,Enum_mem_2 ,Enum_mem_3 } Enum_1;
typedef enum { Enum_mem_4 = 0 ,Enum_mem_5 ,Enum_mem_6 } Enum_2;
static strct_1 Arr[10];
int16 fun_1(Enum_1 str_mem3, int16 abc) { int16 cnt1; int16 val = -1;
for(cnt1 = 0; cnt1 < 10; cnt1++)
{
if(Enum_mem_4 == Arr[cnt1].str_mem4)
{
Arr[cnt1].str_mem1 = 1;
Arr[cnt1].str_mem2 = 2;
Arr[cnt1].str_mem3 = 3;
Arr[cnt1].str_mem4 = Enum_mem_6;
val = cnt1;
break;
}
else {}
}
return val;
}
It would be of great help if someone can send me a sample model at renish_halo@yahoo.com

Respuesta aceptada

Renish Ramegowda
Renish Ramegowda el 20 de Dic. de 2013
I found a way to resolve it. Use class files to define the ENUM Use simulink.bus and Simulink.BusElement to define your STRUCTURE. Then using the mpt.Signal, define your array with DataType as Bus: Name. Now using the Data Store Memory, Selector and Assignment block, you can play around with Array of Structure. This worked with R2013a version of MATLAB. Not sure about previous versions.

Más respuestas (0)

Categorías

Más información sobre Syntax for States and Transitions en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by