⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exm12013_1.cpp

📁 《精通Matlab6.5版》张志勇等编著
💻 CPP
字号:
#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);			//

    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -