gpt4 book ai didi

c - 在 mex 文件中使用 mexCallMATLAB 执行清除命令时出现 Matlab 错误

转载 作者:太空宇宙 更新时间:2023-11-03 23:33:46 25 4
gpt4 key购买 nike

执行提示错误的代码是:

 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] 指向的工作区中的变量。请提出我做错了什么。

使用一个参数执行此函数时的错误消息。给出以下错误信息:

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com