Matlab MEX create struct data type

I want creating MEX function in C/C++ and return struct data type to Matlab. This code can create struct data type with some of variable have int, double, string and matrix (array) data type. We need to use “mxCreateStructArray” matlab function to create struct data in C/C++ and return that struct data type to Matlab.

Please check my C/C++ code to create MEX with return struct data type in Matlab.

Save to mex_return_struct.cpp file (MEX with return struct data type). Compile from matlab command window with command :

Running our MEX with string parameter and string separator :

Sample result :

As you can see, creating struct data type in C/C++ and call from Matlab is very simple.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.