pass 3D Matrix from matlab to C mex- file
Brian Blais
bblais at bryant.edu
Wed Dec 19 08:48:21 EST 2007
On Dec 19, 2007, at Dec 19:5:07 AM, baavour at gmail.com wrote:
> help please
>
> how can i pass 3d matrix from matlab to c
>
> using mex file
>
> thanks
> --
> http://mail.python.org/mailman/listinfo/python-list
wrong mailing list, you might want to try the matlab news group. but,
to answer your question, mex files all have the same syntax:
void mexFunction(
int nlhs, /* number of expected outputs */
mxArray *plhs[], /* mxArray pointer array returning
outputs */
int nrhs, /* number of inputs */
const mxArray *prhs[] /* mxArray pointer array for
inputs */
)
no matter what type of array you pass. you then need to get the data
pointer, the sizes for the arrays, etc... like:
mydata = mxGetPr(prhs[0]);
dims=mxGetDimensions(prhs[0]);
ndims=mxGetNumberOfDimensions(prhs[0]);
check out the mex documentation.
Or, you can use Python with numpy for matrices, and use Pyrex for the
c-extensions and make your life a *lot* easier.
bb
--
Brian Blais
bblais at bryant.edu
http://web.bryant.edu/~bblais
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20071219/18b6ff44/attachment.html>
More information about the Python-list
mailing list