Use mex files in matlab for MAC

115 Ansichten (letzte 30 Tage)
Rui Ascenso
Rui Ascenso am 25 Aug. 2014
Kommentiert: Walter Roberson am 23 Jul. 2019
I need to use a function designed to provide ARMA-Garch-in-Mean estimation in matlab and I found a code online in a mex file. Thing is I don't know what to do next in order to use this function in matlab. I am a mac user and don't even know how to set mex files in matlab for mac. So, pretty much I need to do a ARMA-Garch-in-Mean estimation and have no clue on how to do it.
Can anyone help? What should I do?
I can give you de code or the link where I found it if it helps...
Thanks in advance, Rui

Akzeptierte Antwort

Geoff Hayes
Geoff Hayes am 25 Aug. 2014
Rui - it may be helpful to attach the files so that we know what you code you have. I suspect that you have at least one m-file that calls one or more MEX functions that are in C-files i.e. files with a c extension (written in the C programming language).
I have a Mac as well, and it is easy to build the MEX-functions from C/C++ as per the documentation found at the link MEX.
To setup, you need a C/C++ compiler. In the MATLAB Command Window, type
mex -setup C
What do you see? When I run this command, I observe
MEX configured to use 'Xcode with Clang' for C language compilation.
You may need to install Xcode in order to get a similar compiler. Once a compiler has been chosen, you can build the MEX-files. Change to the directory that contains the *.c files and type the command (in the MATLAB Command Window) to build the MEX-function
mex functionName.c
where functionName is the name of the function/file. You will either observe errors or see that it built successfully
Building with 'Xcode with Clang'.
MEX completed successfully.
In your folder, there will now be a file similar to functionName.mexmaci64.
Repeat the above for each C-file.
Once completed, you can call each MEX-function from within the MATLAB code as if it were a MATLAB function
% call functionName to do something
Z = functionName(A,B);
so long as you provide inputs (and assign outputs) as directed by the function signature.
Try the above and see what happens!
  22 Kommentare
preksha pareek
preksha pareek am 23 Jul. 2019
What if I dont have C file only file with extension .mexa64 is avilable?
Walter Roberson
Walter Roberson am 23 Jul. 2019
You cannot use mexa64 with Mac: those are for Linux only.
There are no tools to decompile .mex* files into matlab source code.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Write C Functions Callable from MATLAB (MEX Files) finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by