Yes. But you have to do it manually piece by piece with the mxCreateStruct, mxGetField, mxSetField, etc. API functions. There is no magic function that will take an arbitrary C/C++ struct and turn it into an mxArray for you.
James Tursa
I was wondering if it should be possible to formulate the problem in
such a way so that the parameters to the mex function would be arrays
and write a wrapper function in MATLAB, that takes care of the
transformation between the representations.
Peter
An m-file wrapper function could get at the individual structure variables and pass them along to the mex routine of course. But that doesn't really save you anything. In fact it just creates a bunch of temporary mxArray header info that you really don't need. The only advantage to this approach IMO is that it may be easier to do some error checking in the m-file vs in a mex routine. Regardless, you will still have to construct your C/C++ struct inside the mex routine ... you can't do it at the m-file level. (Is that what you are asking?). Maybe if you have a specific example of a MATLAB struct and your desired C/C++ struct I could suggest C code that would go back & forth between the two.
James Tursa
If the structures are kept simple with no arrays of pointers than the LOADLIBARY, CALLLIB and LIBSTRUCT commands can be used to pass
a C structure from MATLAB to a c interfaced function.
Take a look at matlabroot\extern\examples\shrlib\shrlibsample.c and the documentation for more information.
Phil
>> sm.p1 = 476; sm.p2 = -299; sm.p3 = 1000
sm =
p1: 476
p2: -299
p3: 1000
>> sc = libstruct('c_struct', sm)
??? Error using ==> feval
Undefined function or method 'lib.c_struct' for input arguments of type 'struct'.
Error in ==> libstruct at 17
ptr=feval(['lib.' structtype],initialvalue);
>>