06.08.2013 Views

内容简介作者简介 - 科学与工程计算系

内容简介作者简介 - 科学与工程计算系

内容简介作者简介 - 科学与工程计算系

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

}<br />

//<br />

if (!mxIsDouble(prhs[1])||mxIsComplex(prhs[1])||!(mrows1==1 && ncols1==1))<br />

mexErrMsgTxt("Inputs must be all noncomplex scalar double.");<br />

//<br />

//<br />

if (mrows0!=mrows1||ncols0!=ncols1) //<br />

mexErrMsgTxt("Inputs must be same dimension."); //<br />

//<br />

plhs[0]=mxCreateDoubleMatrix(mrows0,ncols0,mxREAL); //<br />

x=mxGetPr(prhs[0]); //<br />

z=mxGetPr(prhs[1]); //<br />

y=mxGetPr(plhs[0]); //<br />

myplus(y,x,z);<br />

(3)<br />

cd D:\mywork<br />

mex exm12013_1.cpp<br />

dir exm12013_1.*<br />

exm1213_1.cpp exm1213_1.dll<br />

(4)<br />

a=0.111;b=0.222;<br />

c=exm12013_1(a,b)<br />

c =<br />

0.3330<br />

12.1.4 C MEX 文件的执行流程<br />

12.1.5 编写 C MEX 文件的常用库函数和示例<br />

12.1.5.1 常用的 MEX 库函数<br />

(1)<br />

#include "mex.h"<br />

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

{<br />

3

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

Saved successfully!

Ooh no, something went wrong!