Error message Mex File Matlab

5 ビュー (過去 30 日間)
Rare Pearl
Rare Pearl 2013 年 5 月 25 日
編集済み: Rahul Arora 2018 年 12 月 13 日
Has any one had before this error message "Undefined function or method 'name of function' for inputs arguments of type 'double'. I always have this error message when compiling a mex file. I have checked well the path, and it seems the right one. The mex file is "amortiss.c", the error message "Undefined function or method 'arrayquotient' for input arguments of type 'double'. This is my code:
#include "mex.h"
/* The computational function */ 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]);
/* 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); }
I added the path (command addpath and then savepath) to make sure the mex file "amortiss.c" exists. Then I created a .m file called "arrayquotient.m" in which I just wrote the declaration of my function : function c=arrayquotient(a,b) and that is to make sure that the function arrayquotient exists too.
when compiling an other error message appears: 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". So please Help me !! I would appreciate any suggestion from you. Thanks.

採用された回答

Kaustubha Govind
Kaustubha Govind 2013 年 5 月 29 日
After compilation, you MEX-file should have the name amortiss (same name as the .c file) with a platform-specific extension like .mexw32, .mexw64, etc. Check that the file exists on the path using the command which amortiss to make sure that MATLAB can find the function. You can now call into this function.
Also, in the function arrayquotient, the variable 'output1' is passed in by value, so it's not really being returned to the caller. You may want to pass it in by pointer instead.
  5 件のコメント
Anilkumar Erappanakoppal Swamy
Anilkumar Erappanakoppal Swamy 2018 年 11 月 20 日
Hi,
I have 'computeIntegralHistogramMex.mexa64' extension file also. But even then I get function variable undefined error.
I have added all the subfolders into path. What else could be the problem?
Thanks!
Anil
Rahul Arora
Rahul Arora 2018 年 12 月 13 日
編集済み: Rahul Arora 2018 年 12 月 13 日
This seems to be an issue with R2018b. The cmake folks (https://gitlab.kitware.com/cmake/cmake/merge_requests/2407/diffs?commit_id=956e1b8e55600b9b7562e7cf3d1e05d2853a9c46) figured out that you have to add a compiler option
\EXPORT:mexFunction
to MSVC (I tested it on MSVC 2017 Win64).
It seems the equivalent fix for gcc/clang is the option
-fvisibility=hidden
as discussed here: https://github.com/DIPlib/diplib/issues/13. I don't have a *nix machine to check, though.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWrite C Functions Callable from MATLAB (MEX Files) についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by