Questions tagged [mex]

MEX-files (MEX stands for Matlab EXecutable) are dynamically linked subroutines produced from C, C++ or Fortran source code that, when compiled, can be run from within MATLAB® in the same way as MATLAB functions or built-in functions.

In general, MATLAB can be quite efficient in performing a wide variety of numerical tasks. However, from time to time there are certain tasks that require more "low-level" control over the execution. For these kind of tasks MATLAB allows for an easy interface to C/C++/Fortran subroutine pre-compiled and ready to be used as any built-in function.

Here are some useful links for MEX-files:

1435 questions
40
votes
2 answers

What was the difference between WSDL & Mex Endpoint in WCF

I have couple of question on mex endpoint. In legacy web services, we create a proxy using wsdl. The WSDL exposes the web service's meta data. In wcf, another term comes that mex endpoint, which also exposes meta data, but wsdl is still alive in…
Thomas
  • 31,089
  • 118
  • 335
  • 589
37
votes
4 answers

FFTW vs Matlab FFT

I posted this on matlab central but didn't get any responses so I figured I'd repost here. I recently wrote a simple routine in Matlab that uses an FFT in a for-loop; the FFT dominates the calculations. I wrote the same routine in mex just for…
Justin
  • 4,529
  • 2
  • 33
  • 53
31
votes
2 answers

Embedding Python in MATLAB

I am trying to embed Python 2.6 into MATLAB (7.12). I wanted to embed with a mex file written in C. This worked fine for small simple examples using scalars. However, if Numpy (1.6.1) is imported in anyway MATLAB crashes. I say anyway because I…
Paul Linden
  • 421
  • 4
  • 8
22
votes
2 answers

Matlab mex file is slow compared to its straight C equivalent

I'm at a loss to explain (and avoid) the differences in speed between a Matlab mex program and the corresponding C program with no Matlab interface. I've been profiling a numerical analysis program: int main(){ Well_optimized_code(); } compiled…
Sevenless
  • 2,645
  • 2
  • 24
  • 46
21
votes
13 answers

Using GCC (MinGW) as MATLAB's MEX compiler

I've been given a project to run on MATLAB R2011a. As there are several .c files in there - I need to set up GCC as the MEX compiler for that project. However, I cannot seem to find any explanation as to how to set it up. I've tried a script program…
Menyh
  • 699
  • 1
  • 10
  • 30
21
votes
7 answers

MEX compile error: unknown type name 'char16_t'

I cannot compile any MATLAB MEX code due to the following error: In file included from /Applications/MATLAB_R2013a.app/extern/include/mex.h:58: In file included from…
p0lAris
  • 4,430
  • 7
  • 37
  • 78
17
votes
3 answers

How to build mex file directly in Visual Studio?

I have a Visual Studio 2010 solution that contains a library of functions, and I would like to be able to use MATLAB as one of several possible front-ends to this library. Therefore, I would like Visual Studio to automatically generate a mex file…
j0rre
  • 509
  • 1
  • 5
  • 13
17
votes
3 answers

Is it possible to debug mex code with Eclipse?

I am trying to write some mex code but it is painful to debug it on the console with gbd. Is it possible to use Eclipse or the GUI of Matlab? If these are not feasible methods, what is the best way of writing mex code that provides good debug…
erogol
  • 11,182
  • 28
  • 90
  • 144
14
votes
2 answers

How do I profile a MEX-function in Matlab

I have a Mex-function (a function in c++ that you can call from Matlab) that I have written, and I want to profile it using valgrind/kcachegrind. I know how to use valgrind/kcachegrind if you are running a c++ program directly, but is there a way…
Alex319
  • 3,640
  • 9
  • 29
  • 39
13
votes
1 answer

MATLAB no longer unloading MEX-files after upgrade to macOS Mojave

In MATLAB, clear mex unloads all MEX-files from memory (unless they're locked). Under previous versions of macOS, I was able to re-compile a MEX-file and run the modified version without restarting MATLAB, simply by issuing a clear mex command. This…
Cris Luengo
  • 43,236
  • 6
  • 46
  • 92
12
votes
8 answers

How to tell mex to link with the libstdc++.so.6 in /usr/lib instead of the one in the MATLAB directory?

Now mex in MATLAB 2012a only officially supports gcc 4.4.6 but I want to use gcc 4.7 at my own risk. Now If I compile something with mex directly, it will complain…
ziyuang
  • 3,604
  • 4
  • 34
  • 69
12
votes
2 answers

matlab compiler installation problems

I'm trying to run a compiler on MATLAB but things don't go as expected. How can I properly install MATLAB and how can I check what exactly is going wrong. I have the MATLAB r2013a version. I've done as follow: I've downloaded the SDK 7.1 file from…
user2694285
  • 139
  • 1
  • 2
  • 9
11
votes
1 answer

Setting the *default* data order (C vs. Fortran) in Numpy

I'm porting some MATLAB code to Numpy. This task includes stripping the MEX out of some C++ code and replacing it with equivalent calls to Numpy's C-API. One problem is that the MEX code treats the incoming data as Fortran-ordered because that's how…
BrianTheLion
  • 2,440
  • 2
  • 22
  • 43
11
votes
4 answers

Error: Invalid MEX file, the specified module could not be found

I have compiled Mex file successfully on my laptop. But when I am running it, it says Invalid mex file 'c:\newfolder\filename.mexw32' The specified module could not be found. System specification: OS: windows 7 MATLAB 2010a Microsoft Visual…
anand
  • 111
  • 1
  • 1
  • 6
11
votes
1 answer

Using boost in MATLAB MEX library, different from MATLAB's version

We're creating a number of MATLAB MEX files that use our communications library. This communication library uses Boost a lot. Now, MATLAB also uses boost internally, which means that in a standard setup, we cannot use a boost version different from…
Ives
  • 240
  • 2
  • 9
1
2 3
95 96