Matlab 错误消息Mex文件

Matlab 错误消息Mex文件,matlab,mex,Matlab,Mex,在此错误消息之前是否有任何人: 输入参数类型为“double”的未定义函数或方法“函数名”。 编译mex文件时,我总是会收到此错误消息。我已经仔细检查了这条路,它似乎是正确的 这是我的代码,mex文件是amoritis.c #include "mex.h" /* The computational functions */ void arrayquotient(double input1, double input2, double output1) { output1=input1/

在此错误消息之前是否有任何人:

输入参数类型为“double”的未定义函数或方法“函数名”。

编译mex文件时,我总是会收到此错误消息。我已经仔细检查了这条路,它似乎是正确的

这是我的代码,mex文件是
amoritis.c

#include "mex.h"

/* The computational functions */
void arrayquotient(double input1, double input2, double output1)
{

   output1=input1/input2;

}


/* The gateway function */
void mexFunction( int nlhs, mxArray *plhs[],
                  int nrhs, const mxArray *prhs[])
{
/* variable declarations here */
    double input1;      /* input scalar 1 */
    double input2;       /* input scalar 2*/
    double output1;      /* output scalar 1 */   

/* code here */
    /* get the value of the scalar input1  */
   input1 = mxGetScalar(prhs[0]);

/* get the value of the scalar input2 */
   input2 = mxGetScalar(prhs[1]);

/* get the value of the scalar input3 */
   input3 = mxGetScalar(prhs[2]);

/* create the output scalar1 */
    plhs[0] = mxCreateDoubleScalar(input1/input2);

/* get the value of the scalar output1 */
   output1 = mxGetScalar(plhs[0]);

/* call the computational routines */
arrayquotient(input1,input2,output1);
}
我添加了路径(命令addpath)以确保mex文件
amoritis.c
存在。然后,我创建了一个名为
arrayquotient.m
的.m文件,在其中我刚刚编写了我的函数声明:

函数c=arrayquotient(a,b)

但是,在编译时,会出现另一条错误消息:

Error in ==> arrayquotient at 1
function c=arrayquotient(a,b)

??? Output argument "c" (and maybe others) not assigned during call to
"C:\Users\hp\Documents\MATLAB\codes_Rihab\arrayquotient.m>arrayquotient".

函数
amorisis.c
是一个c文件,不能像Matlab那样执行。
您创建的文件
arrayquotient.m
是一个空函数,它不会为其输出
c
赋值

您需要做的是mexc-file
amoritis.c
来创建一个mex文件
amoritis.mexw32
(扩展名根据您的体系结构而不同。使用
mexext
查找您应该查找的扩展名)

在matlab中,设置mex编译器:

>> mex -setup
您将被指示从安装在您的机器上并由Matlab识别的编译器中进行选择

一旦您设置了mex编译器,就可以继续对c文件进行mex

>> mex -O -largeArrayDims amortiss.c
然后,您将拥有一个mex文件
amoritis.mexXXX
(根据您的体系结构使用“XXX”。
您可以像任何其他函数一样cll该函数

>> c = amortiss( a, b );

你确定你是真的吗?通常你会得到“未定义函数等”,如果你没有编译函数的话。我有点困惑。您试图编写的函数名为
摊销
还是
数组商
?除非使用正确的标志进行编译,否则编译后的mex文件将是摊销。请报告
哪个数组商-all
哪个摊销-all
的结果。在
数组商
中对参数
output1
的赋值不会改变
mexFunction
中的不同变量
output1
。如果分配了
mexFunction
中的
output1
,则仅此一项不会改变
plhs[0]
中的值。你应该检查<代码> NRS< <代码>,以免在坏处输入崩溃Matlab。谢谢大家的响应。我的MEX文件是“AMORISTIC.C”,并且这个函数叫做“AdalyQualToNe.'。我用微软Visual C++ 2008 Express编译器编译了MEX文件,但是一旦我进入了RePioDeI,我就找不到“.MexW32”文件,也没有“Adjiq”。“amoritis.c”文件的功能。你认为这就是问题所在吗?我现在能做什么?谢谢你的帮助!!@Shai,谢谢你的回复。我已经做了你说的,我选择了编译器:微软Visual C++ 2008 Express。我也删除了M文件“ArayQualTo.m”。然后我输入的是:MEX AMORISS。C>C=2。b=3;>>d=阵列商(c,b)???无效的MEX文件“C:\Users\hp\Documents\MATLAB\ArrayQuotent.mexw32”:C:\Users\hp\Documents\MATLAB\ArrayQuoter.mexw32不适用于Unie应用程序Win32 valide。我现在该怎么办???我感谢你的帮助!!
>mexext
的输出是什么?当我键入>>mexext时,它会给我:mexw32您应该删除
arrayquotient.mex32
并运行
>c=amoritis(a,b)我更改了函数的名称,它工作得很好。就是这么简单。无论如何,非常感谢您宝贵的帮助。目前,它工作得很好。非常感谢你的建议和帮助。