现在的位置: 首页 > 综合 > 正文

mexCallMATLAB(1,OUT,1,prhs,”‘”) mexCallMATLAB(0,IN,1,OUT,”disp”);

2013年10月10日 ⁄ 综合 ⁄ 共 460字 ⁄ 字号 评论关闭
#include "mex.h"
/*下面这个mexFunction的目的是使MATLAB知道如何调用这个函数*/ 
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
 {
	double *inData,*outData;
	mxArray *IN[1];
	mxArray *OUT[1];
	int M,N;
	int i,j;

	 if(nrhs!=1) 
	   mexErrMsgTxt("One input required.\n"); 
	 if(!mxIsDouble(prhs[0]))
	   mexErrMsgTxt("input Matrix must be double.\n"); 

	 //计算转置
	 if(mexCallMATLAB(1,OUT,1,prhs,"'"))
		mexErrMsgTxt("Error when compute.\n"); 

	 //根据输入参数数目决定是否显示
	 if(nlhs==0)
		mexCallMATLAB(0,IN,1,OUT,"disp");
	 else
		 plhs[0]=OUT[0];
}

抱歉!评论已关闭.