필터 지우기
필터 지우기

Matlab model for Array of structure possible?

조회 수: 2 (최근 30일)
Renish Ramegowda
Renish Ramegowda 2013년 12월 13일
답변: Renish Ramegowda 2013년 12월 20일
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