Filter löschen
Filter löschen

Matlab model for Array of structure possible?

2 Ansichten (letzte 30 Tage)
Renish Ramegowda
Renish Ramegowda am 13 Dez. 2013
Beantwortet: Renish Ramegowda am 20 Dez. 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

Akzeptierte Antwort

Renish Ramegowda
Renish Ramegowda am 20 Dez. 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.

Weitere Antworten (0)

Kategorien

Mehr zu Syntax for States and Transitions finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by