How to create a structure and pass that structure's object as a pointer to a C function in Matlab/Simulink
Show older comments
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.
Accepted Answer
More Answers (0)
Categories
Find more on Simulink Coder in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!