How to create a structure and pass that structure's object as a pointer to a C function in Matlab/Simulink
Ältere Kommentare anzeigen
Hello team,
We need to access a C-function in Matlab. This C function has a double pointer of structure type as an argument. Function updates the pointer with an address of structure field.
% % C code: Function in C
void C_function (structure1** ptr)
{
*ptr = &structure1_Obj.info
}
In order to access this function in Matlab (Using matlab function), we need to create the same structure in matlab to pass its object's pointer as an argument to the C function. So eventually, we will get the expected result available in Matlab. Hereby sharing the C code structure architectures for your reference:
% % C code: Structure(Nested) in C
typedef struct structure1
{
another_Structure info;
}structure1_Obj;
% % C code: Structure in C
typedef struct another_Structure
{
char name[50];
int age;
float height;
}
Please guide us to create the similar structure in Matlab in order to get the expected results in Matlab for further use.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Write C Functions Callable from MATLAB (MEX Files) finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
