?? exm12013_1.cpp
字號(hào):
#include "mex.h" //
//
void myplus(double y[],double x[],double z[])
{
y[0]=x[0]+z[0];
}
//
void mexFunction(int nlhs,mxArray *plhs[],
int nrhs,const mxArray *prhs[])
{
double *x,*y,*z;
int mrows0,ncols0;
int mrows1,ncols1;
//
if (nrhs!=2)
mexErrMsgTxt("Two inputs required.");
else if (nlhs>1)
mexErrMsgTxt("Too many output arguments");
mrows0=mxGetM(prhs[0]); //
ncols0=mxGetN(prhs[0]); //
mrows1=mxGetM(prhs[1]); //
ncols1=mxGetN(prhs[1]); //
//
if (!mxIsDouble(prhs[0])||mxIsComplex(prhs[0])||!(mrows0==1 && ncols0==1))
mexErrMsgTxt("Inputs must be all noncomplex scalar double.");
if (!mxIsDouble(prhs[1])||mxIsComplex(prhs[1])||!(mrows1==1 && ncols1==1))
mexErrMsgTxt("Inputs must be all noncomplex scalar double.");
if (mrows0!=mrows1||ncols0!=ncols1)
mexErrMsgTxt("Inputs must be same dimension.");
plhs[0]=mxCreateDoubleMatrix(mrows0,ncols0,mxREAL); //
//
x=mxGetPr(prhs[0]); //
z=mxGetPr(prhs[1]); //
y=mxGetPr(plhs[0]); //
myplus(y,x,z); //
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -