FAQ Database Discussion Community


Matlab 2014b and mex files, has anyone been able to use Visual Studio Express?

matlab,visual-studio,windows-7-x64,mex
I know that Visual Studio Pro will allow you to compile mex files for MATLAB 2014b. However I was wondering if anyone was able to use Visual Studio Express (which is free, as opposed to Pro which is not) to compile mex files? I tried the Windows SDK (recommended by...

Fortran in MatLab - Error in mex Setup

matlab,mex
I am trying to use a .F90 file, calling it from an m-file. From the little I've read, I am supposed to use this mex setup to get things going. I have installed Intel Parallel Studio 2015 and Windows SDK 8. Now from the error below, I suspect that MatLab...

Locating and/or calling a built-in MATLAB MEX file

matlab,mex
I'm reading through some MATLAB source code in order to translate MATLAB's imhist to Python. Inside imhist, the following call is made: y = imhistc(a, n, isScaled, top); % Call MEX file to do work. As the comment implies, imhistc comes from a MEX file. I can open and run...

Invalid mex-file, libarmadillo, cannot open shared object file

matlab,shared-libraries,mex,armadillo
I know there are a lot of posts about the topic, this might be a duplicate, but I don't think so. My config is: Matlab R2014b, clang 3.4, Ubuntu 14.04, armadillo-4.600.4. I have a local install (not system-wise, so including/linking manually) of Armadillo that works fine when outside of Matlab....

Cannot compile MEX LAPACK example

matlab,mex,lapack
Summary I am trying to write some MEX files that use LAPACK, and I thought I'd start by looking through the examples provided by MathWorks. However, I am having some trouble compiling them. After copying the matrixDivide.c example from [MATLAB root]/extern/examples/refbook into a working directory, I tried to build a...

MEX fortran file using Gnumex and MinGW (g77)

matlab,fortran,mex,fortran77
There is a problem that I ran into recently. It used to be working fine as far as I remember but after a few week I am trying again to MEX a fortran 77 file in MATLAB but it is giving me a weird error. Ok, I made the MEX...

Can I detect MATLAB termination other than by way of a mex file mexAtExit handler?

matlab,mex
tl;dr Is there any way in a Matlab .m file to detect that Matlab termination is under way? I have an unmanaged library that provides an interface to my product. I have wrapped that for Matlab using a mex file. So my unmanaged library exists as a Windows DLL. I...

How to install SPAMS toolbox in Matlab 2014b under windows 8.1

c++,matlab,mex
I am trying to learn how to successfully compile "Sparse Modeling Software" (SPAMS) in my machine which uses a Windows 8.1 OS and MATLAB R2014b. The steps I have taken are as followed (some parts might have been unnecessary or missing) Step 1. Installed "Microsoft Visual C++ 2013 Professional". Step...

Mex File dot product

c,matlab,mex
I'm trying to implement some elementary linear algebra routines in MEX files in C for practice, and I'm stuck with dot products. Here's what I have so far: #define char16_t UINT16_T //shenanigans with the compiler #include "mex.h" void dotProd(double *a, double *b, double z, mwSize n) { mwSize i; for(i=0;i<n;i++){...

Multithreaded (pthreads) MATLAB mex function causes MATLAB to crash after exiting

c,multithreading,matlab,pthreads,mex
I have a task that I need to perform in MATLAB many times, and I would like to reduce the amount of time taken to perform the task by using a multithreaded MEX function. However, I'm running into a little snag where the MEX function causes MATLAB to crash after...

How can I use C generated code from Simulink into a MATLAB script

c,matlab,simulink,mex
Here is my problem: We would like to use our different Simulink models within a script in a much faster way than having to open the Simulink environment (our MATLAB script using Simulink is launched many time). For that purpose, I want to transform the Simulink model into a C...

OpenMP Matrix-Vector Multiplication Executes on Only One Thread

c++,multithreading,parallel-processing,openmp,mex
I have this code (outlined below) for parallelizing matrix-vector multiplication. But whenever I run it, I discover that it is executing on just one thread (even though I specified 4). How can I separate parts of the parallel code to run on separate threads. Any help will be highly appreciated....

Creating and Passing of mxArray Data from other functions to Mex gateway function

c,matlab,mex
Ok guys, I feel as if I'm falling into the rabbit hole... To build an interface as a Matlab-Mex that receives several different messages which consist of complicated C-structs, I want to create the corresponding Mex-Structs each in different functions. Is it somehow possible to pass mxArrays that contain fields...

Error when compiling/mexing imrender function with OS X in Matlab

c++,osx,matlab,mex
I am trying to use a specific function in Oliver Woodford's imrender_v2.4.zip (http://www.robots.ox.ac.uk/~ojw/software.htm) in Matlab, specifically the vgg_qpbo function. The related files are supposed to recognize that a mex-file does not exist and compile one. However, after running startup.m and trying something like >> vgg_qpbo(1,1,1) I get Warning: Missing MEX-file:...

How to print C-preprocessor variables like __LINE__ with mexErrMsgTxt() In Matlab MEX

c++,c,debugging,mex,c-preprocessor
For debugging Matlab-MEX, which can be quite a hassle, it would be nice to have better assertion capabilities. Following this question about mex-assertions, it is possible to define a preprocessor makro, that throws an error to Matlab and prints a string (can mostly replace mxAssert, which unfortunately crashes Matlab2011b). #define...

mex error 206 Matlab

c++,matlab,mex
The cpp code I received for a project isn't working so I want to compile and see if it compiles. It didn't compile, but I tried compiling another cpp file that I know works just to see what would happen. In both cases I get the following error: EDU>> mex...

finding local mean in an image using mex-cuda

matlab,cuda,mex
I have an image named HSIImage, of size is 565x585, in which I have find the local mean and standard deviation at every pixel. For this I am using a window W of size 9x9, if we a re finding the mean of x(i,j) we need values in the W...

How do use FFTW lib file in MATLAB MEX-file?

c,matlab,mex,fftw
I am trying to use the FFTW library in a MATLAB MEX-file. I get this library from FFTW.ORG for Windows and make lib files by using this code lib /def:libfftw3-3.def lib /def:libfftw3f-3.def lib /def:libfftw3l-3.def Then when I use those files directly in VC++ (Visual Studio 2013) with this code #include...

compile .C file Include library using mex - error LNK2019: unresolved external symbol - for NPTrackingTools

c,matlab,visual-c++,3d,mex
Hello I'm trying to build simple C function with external commands provide by library NPTrackingTools API #include <stdio.h> #include "mex.h" #include "NPTrackingTools.h" void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int ret1,ret2,ret3; ret1=TT_Initialize(); ret2=TT_FinalCleanup(); ret3=TT_Shutdown(); printf("Hello, World! \n"); return 0; } I tried the following compiler code...

Beginner's Mex Error - MatLab

matlab,fortran,mex
I am beginning to use the mex setup to call fortran files from matlab. What I am trying to do is call a fortran subroutine inside an m-file. From what I've read, I need to run: mex filename.f90 However, when I do that, I get lots of error messages of...

Passing a big matrix from Matlab to C using mex: Matlab crashes

c++,c,matlab,matrix,mex
I have written a mex code which sends a scalar and a matrix to C-code from matlab code. It works fine with smaller matrix. However, when I try to pass big sparse matrix (size ~ 8448 x 3264), matlab crashes with following error: I get the following error: Matlab has...

free() and mxFree() in MATLAB - freeing memory twice

matlab,memory-management,free,mex
Good day, I have the following code which has given me problems for a day already. I have debugged it, and it works fine until trying to free the memory. The free() function should be called at the end of the execution automatically, so I commented the mxFree() code out,...

how to understand the linkagemex function inside of the defaule linkage function in matlab

matlab,mex
I need to rewrite the linkage function in matlab. Now, as I examine it, I realized there is a method called linkagemex inside of it. But I simply cannot step into this method to see its code. Can anyone help me out with this strange situastion? function Z= linkage (Y,...

Matlab Crahes upon fopen in Mex File

c,matlab,fopen,mex
I have a little experience with Matlab, but am new to the mex environment. What I am trying to do is to save some values I compute to a txt file in my C routine. For the sake of simplicity I am using the example arrayProduct.c from MathWork's Create C...