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.
Matlab model for Array of structure possible?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Renish Ramegowda
il 13 Dic 2013
Risposto: Renish Ramegowda
il 20 Dic 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;
}
0 Commenti
Risposta accettata
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Syntax for States and Transitions in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!