求助 MATLAB 接口编程
C函数代码/*
*fact.c - returns the factorial of a nonnegative integer.
*
*MATLAB usage: p=fact(n)
*
*Mastering MATLAB 7 C MEX Example 1
*/
#include "mex.h"
void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[] )
{
double n, j, *p;
int i;
n=mxGetScalar(prhs[0]);
plhs[0]=mxCreateDoubleMatrix(1.1,mxREAL);
p=mxGetPr(plhs[0]);
j=1.0;
for (i=n;i>1;i--)
j=j*i;
*p=j;
}
当在matlab 中运行 mex fact.c 时出现下面的错误提示
fact.c(18) : warning C4244: 'function' : conversion from 'const double ' to 'int ', possible loss of data
fact.c(18) : error C2198: 'mxCreateDoubleMatrix_700' : too few actual parameters
fact.c(22) : warning C4244: '=' : conversion from 'double ' to 'int ', possible loss of data
不胜感激!h