📄 randomnum.c
字号:
/*MEX function example,create random numbers——randomnum.c*/
#include "mex.h"
/*MEX function entrance*/
void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
{
double *m,*n,*flag;
/*error detecting*/
if(nlhs>1||nrhs!=3)
mexErrMsgTxt("error:wrong numbers of input/output!");
m=mxGetPr(prhs[0]);
n=mxGetPr(prhs[1]);
flag=mxGetPr(prhs[2]);
plhs[0]=mxCreateDoubleMatrix(*m,*n,mxREAL);
/*set output flag*/
mexSetTrapFlag(*flag);
/*wrong transfer-->function rnd does not exsit*/
mexCallMATLAB(1,plhs,2,prhs,"rnd");
/*continue to run MEX function file so rand function is transfered by MEX file*/
mexPrintf("user set Flag to 1.\n");
/*rright transfer*/
mexCallMATLAB(1,plhs,2,prhs,"rand");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -