01.09.2013 Views

Using external libraries with MATLAB, MEX files

Using external libraries with MATLAB, MEX files

Using external libraries with MATLAB, MEX files

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Examples of C <strong>MEX</strong>-Files:<br />

Passing a Scalar<br />

• Computational module<br />

#include <br />

void timestwo(double y[], double x[])<br />

{<br />

y[0] = 2.0*x[0];<br />

return;<br />

}<br />

• <strong>MEX</strong>-file<br />

#include "mex.h"<br />

void timestwo(double y[], double x[])<br />

{<br />

y[0] = 2.0*x[0];<br />

}<br />

void mexFunction(int nlhs, mxArray *plhs[], int nrhs,<br />

const mxArray *prhs[])<br />

{<br />

double *x, *y;<br />

int mrows, ncols;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!