Matlab model for Array of structure possible?

2 次查看(过去 30 天)
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

采纳的回答

Renish Ramegowda
Renish Ramegowda 2013-12-20
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Syntax for States and Transitions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by