sharing everything

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.

My name is Toto Sugito. This is my notes when I try something. Maybe, this is NOT THE BEST SOLUTION for your problems. If you have other method or idea that better with my post, please share in this blog. Thank for visiting my site.

No Comments Yet

Leave a Reply

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

 

Categories

Bloggers - Meet Millions of Bloggers