执行提示错误的代码为:
void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
{
double p;
p = (double)mxGetScalar(prhs[0]);
mexCallMATLAB(0,NULL,1, prhs, "clear");
}
我试图清除 prhs[0] 指向的工作区中的变量。 请指出我做错了什么。
使用一个参数执行此函数时出现错误消息。给出以下错误消息:
block 引用>callmatlabtest(10) ??? Error using ==> clear Argument must contain a string.
最佳答案
我相信您的通话中需要包含 &prhs[0]
:
mexCallMATLAB(0, NULL, 1, &prhs[0], "clear");
我已经测试了这段代码并且它可以工作(在名为 mextest.c 的文件中):
#include "mex.h"
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
mexCallMATLAB(0,NULL,1, &prhs[0], "clear");
}
这是结果:
>> a = 10;
>> who
Your variables are:
a
>> mextest('a')
>> who
>>
关于c - 在 mex 文件中使用 mexCallMATLAB 执行清除命令时出现 Matlab 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9297100/