<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Monaco; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div><br class="webkit-block-placeholder"></div><div><div><div>On Dec 19, 2007, at Dec 19:5:07 AM, <a href="mailto:baavour@gmail.com">baavour@gmail.com</a> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">help please</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">how can i pass 3d matrix from matlab to c</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">using mex file</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">thanks</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">-- </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><a href="http://mail.python.org/mailman/listinfo/python-list">http://mail.python.org/mailman/listinfo/python-list</a></div></blockquote></div><div><br class="webkit-block-placeholder"></div><div>wrong mailing list, you might want to try the matlab news group. but, to answer your question, mex files all have the same syntax:</div><div><br class="webkit-block-placeholder"></div><div><div>void mexFunction(</div><div>                 int nlhs,        /* number of expected outputs */</div><div>                 mxArray *plhs[], /* mxArray pointer array returning outputs */</div><div>                 int nrhs,        /* number of inputs */</div><div>                 const mxArray *prhs[]  /* mxArray pointer array for inputs */</div><div>                 )</div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div>no matter what type of array you pass.  you then need to get the data pointer, the sizes for the arrays, etc... like:</div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div></div><div>mydata  = mxGetPr(prhs[0]);</div><div><div>dims=mxGetDimensions(prhs[0]);</div><div>ndims=mxGetNumberOfDimensions(prhs[0]);</div><div><br class="webkit-block-placeholder"></div><div><br></div></div><div>check out the mex documentation.  <br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div>Or, you can use Python with numpy for matrices, and use Pyrex for the c-extensions and make your life a *lot* easier.</div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div><span class="Apple-tab-span" style="white-space: pre; ">                               </span>bb<br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><br><div><div>-- </div><div>Brian Blais</div><div><a href="mailto:bblais@bryant.edu">bblais@bryant.edu</a></div><div><a href="http://web.bryant.edu/~bblais">http://web.bryant.edu/~bblais</a></div><div><br class="khtml-block-placeholder"></div></div></div></span></div><br></body></html>