ttcallblocksystem.cpp

来自「一个很棒的网络控制系统仿真软件」· C++ 代码 · 共 50 行

CPP
50
字号
#define KERNEL_MATLAB#include "../ttkernel.h" RTsys *rtsys;#include "../callblocksystem.cpp"#include "getrtsys.cpp"void mexFunction( int nlhs, mxArray *plhs[],                  int nrhs, const mxArray *prhs[] ){  rtsys = getrtsys() ; // Get pointer to rtsys   // Check number and type of arguments.   if (nrhs != 3) {    mexErrMsgTxt("ttCallBlockSystem: Wrong number of input arguments!\nUsage: ttCallBlockSystem(nbrOutp, inpVec, blockname)");  }  if (!mxIsDoubleScalar(prhs[0])) {    mexErrMsgTxt("ttCallBlockSystem: nbrOutp must be a number");  }  if (!mxIsDouble(prhs[1])) {    mexErrMsgTxt("ttCallBlockSystem: inpVec must contain numbers");  }  if (mxIsChar(prhs[2]) != 1 || mxGetM(prhs[2]) != 1) {    mexErrMsgTxt("ttCallBlockSystem: blockname must be a non-empty string");  }  int nbrOutp = (int) *mxGetPr(prhs[0]);  double* outpVec = new double[nbrOutp];  int nbrInp = mxGetNumberOfElements(prhs[1]);  double* inpVec = mxGetPr(prhs[1]);    char blockname[100];  mxGetString(prhs[2], blockname, 100);  ttCallBlockSystem(nbrOutp, outpVec, nbrInp, inpVec, blockname);  plhs[0] = mxCreateDoubleMatrix(1, nbrOutp, mxREAL);  // Copy values (will be zeros if call failed)  for (int i=0; i<nbrOutp; i++) {    mxGetPr(plhs[0])[i] = outpVec[i];  }    delete[] outpVec;}

⌨️ 快捷键说明

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