mex_mysin1.c

来自「本人收集的一些有关matlab的代码程序设计 也不知道改选什么分类」· C语言 代码 · 共 21 行

C
21
字号
   #include "matrix.h"
/*   #include "math.h"*/
   /*Function mex_mysin1*/
   #define M 63
   void mexFunction( int nlhs, mxArray *plhs[],
                     int nrhs, const mxArray *prhs[])
   {
      mxArray *rhs[2];
      int i;
      double *pB1, *pB2, t;
      if (nrhs!=0) mexErrMsgTxt("Wrong number of input arguments!");
      if (nlhs>1) mexErrMsgTxt("Too many output arguments!");
      rhs[0]=mxCreateDoubleMatrix(1,M,mxREAL); pB1=mxGetPr(rhs[0]);
      rhs[1]=mxCreateDoubleMatrix(2,M,mxREAL); pB2=mxGetPr(rhs[1]);
      t=0;
      for (i=0; i<M; i++) {
         pB1[i]=t; pB2[2*i]=sin(t); pB2[2*i+1]=cos(t); t+=0.1;
      }
      mexCallMATLAB(1,plhs,2,rhs,"plot");
   }

⌨️ 快捷键说明

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