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

📄 randomnum.c

📁 MATLAB 7.0从入门到精通,的所有源代码!!!所在类别: 随书资源/T 工业技术/TP 自动化技术、计算机技术/TP31 计算机软件 其他题名: 作者: 求是科技编著 出版者: 人民
💻 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 + -