timestwo.cpp
来自「斯坦福Energy211/CME211课《c++编程——地球科学科学家和工程师》」· C++ 代码 · 共 29 行
CPP
29 行
#include "mex.h"void timestwo_alt( double *y, double x ){ *y = 2.0 * x;}void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ){ // Create a 1-by-1 matrix for the return argument plhs[0] = mxCreateDoubleMatrix( 1, 1, mxREAL ); // Get the scalar value of the input x // Note: mxGetScalar returns a value, not a pointer double x = mxGetScalar( prhs[0] ); // Assign a pointer to the output double *y = mxGetPr( plhs[0] ); // Call the timestwo_alt subroutine to do the real // work. Because y is pointing to the location // where MATLAB is storing the output value, we // only need to store the result at y for it to // be passed back to MATLAB automatically timestwo_alt(y, x);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?