assume that a C program has a structure instantiated as follows:
b.param1 = 20;
b.parm2 = 42;
b.param3 = 30;
The question is, what do we need to do or to have to be able to write from Matlab
>> b = [bInC.param1; bInC.param2; bInC.param3];
where bInC points to the memory allocated by the above mentioned C program
You have a couple options, depending on your situation.
1) If your C code is structured in such a way that it could be called from matlab, you can compile your C code as a mex file. You would then call your C function from matlab and return your result. To return your structure you have to create a matlab array in your C code and copy the structure parameters into it. The interface for this is the mxArray. It isn’t the most convenient process ever but it works well.
mex files and mxArray: http://www.mathworks.com/help/techdoc/matlab_external/f29502.html
2) Use the matlab engine to load your values into matlab without having to compile your code into a mex. The engine will let you execute matlab commands from your C program. You can also load variables into the workspace. You will still have to create an mxArray containing the values you want to copy. You can then use the engPutVariable function to copy the mxArray into your matlab workspace.
Note that the engine maintains its own workspace, it will not automatically copy the variable into the workspace of your current matlab session by default. There are commands to move variables between workspaces but I have not investigated this. I have found it faster to just save the variables to a mat file and load it in the main workspace, but this is not ideal if you need an automated approach.
matlab engine: http://www.mathworks.com/help/techdoc/matlab_external/f29148.html