mex

Debug a mex function in Visual Studio

纵然是瞬间 提交于 2019-11-30 23:34:00
I'm trying to wrap existing C++ code into a MATLAB callable function. I'm using Visual Studio 2013 to generate the MEX file . The MEX file is created properly, I can call it from MATLAB and pass arguments back and forth without any issues. Now I want to debug my C++ logic, and I can't seem to get it to work. I've created an m script that calls my function, and had Visual Studio run MATLAB when debugging - as explained here . When I hit F5 to debug my MEX file, Visual Studio runs MATLAB, and then exits debug mode very quickly, as if the MATLAB process terminated. A few seconds after that ,

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

会有一股神秘感。 提交于 2019-11-30 23:10:33
问题 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 Studio 2008. The same mex file is compiled and run successfully on my PC under XP SP3. 回答1: This MathWorks support link suggests two possible reasons to your problem: You do not have all of the necessary libraries that the MEX-function is dependent upon.

Tomcat and Matlab MCR invalid MEX-file error

不问归期 提交于 2019-11-30 19:58:26
问题 I have Tomcat 7 and MCR 8.3 installed on my Ubuntu 14.04 server. Matlab is correctly installed, because I can execute some program, but when I try to execute others i have this error: Invalid MEX-file '/usr/local/MATLAB/MATLAB_Compiler_Runtime/v83/mcr/toolbox/matlab/sparfun/etree.mexa64': libmwarpack.so: cannot open shared object file: No such file or directory I set the environment in my /etc/profile.d folder in this way: MCR_ROOT=/usr/local/MATLAB/MATLAB_Compiler_Runtime/v83 export PATH=

Calling methods of C++ class in MEX from MATLAB

坚强是说给别人听的谎言 提交于 2019-11-30 15:44:41
I have a DLP kit which I need to control via MATLAB using a C++ API. Say, I have functions/methods using C/C++ for {load_data, load_settings,display_data} in a mex file named dlp_controller.cpp/.c. I know I can call dlp_controller(); with MATLAB. Is there a way I can call the method of this mex from MATLAB directly? Say my dlp_controller.cpp mex looks as: class dlp{ ... } dlp::dlp{ ... } dlp::load_data{ ... } dlp::load_settings{ ... } dlp::display_data{ ... } void mexFunction(int nlhs, mxArray *[],int nrhs, const mxArray *prhs[]{ ... } Can I somehow call the methods like dlp_controller.load

How do I profile a MEX-function in Matlab

 ̄綄美尐妖づ 提交于 2019-11-30 14:43:13
问题 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 to do this profiling if I am calling the c++ program from Matlab? 回答1: Profiling MEX files is tricky since the MEX files are shared libraries. It can not be done on Linux using standard 'gprof' approach - gprof simply does not do that. I tried to use

mex linking of cuda code in separate compilation mode

给你一囗甜甜゛ 提交于 2019-11-30 10:29:55
I'm trying to use CUDA code inside MATLAB mex, under linux. With the "whole program compilation" mode, it works good for me. I take the following two steps inside Nsight: (1) Add "-fPIC" as a compiler option to each .cpp or .cu file, then compile them separately, each producing a .o file. (2) Set the linker command to be "mex" and add "-cxx" to indicate that the type of all the .o input files are cpp files, and add the library path for cuda. Also add a cpp file that contains the mexFunction entry as an additional input. This works good and the resulted mex file runs well under MATLAB. After

Matlab mex-file with mexCallMATLAB is almost 300 times slower than the corresponding m-file

那年仲夏 提交于 2019-11-30 09:32:10
I started implementing a few m-files in C++ in order to reduce run times. The m-files produce n-dimensional points and evaluate function values at these points. The functions are user-defined and they are passed to m-files and mex-files as function handles. The mex-files use mexCallMATLAB with feval for finding function values. I constructed the below example where a function handle fn constructed in the Matlab command line is passed to matlabcallingmatlab.m and mexcallingmatlab.cpp routines. With a freshly opened Matlab, mexcallingmatlab evaluates this function 200000 in 241.5 seconds while

shared library locations for matlab mex files:

家住魔仙堡 提交于 2019-11-30 08:56:46
I am trying to write a matlab mex function which uses libhdf5; My Linux install provides libhdf5-1.8 shared libraries and headers. However, my version of Matlab, r2007b, provides a libhdf5.so from the 1.6 release. (Matlab .mat files bootstrap hdf5, evidently). When I compile the mex, it segfaults in Matlab. If I downgrade my version of libhdf5 to 1.6 (not a long-term option), the code compiles and runs fine. question: how do I solve this problem? how do I tell the mex compilation process to link against /usr/lib64/libhdf5.so.6 instead of /opt/matlab/bin/glnxa64/libhdf5.so.0 ? When I try to do

matlab compiler installation problems

岁酱吖の 提交于 2019-11-30 08:47:17
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 here destination folder for Tools: C:\Program Files\Microsoft SDKs\Windows\v7.1 destination folder for Samples: C:\Program Files\Microsoft SDKs\Windows\v7.1\Samples I've added my compiler directories to the path environment Control Panel -> System -> "Advanced" -> "Environment variables". new system variable with the name "MSSdk". value of this

How to speed up Eigen library's matrix product?

左心房为你撑大大i 提交于 2019-11-30 07:31:09
I'm studying simple multiplication of two big matrices using the Eigen library. This multiplication appears to be noticeably slower than both Matlab and Python for the same size matrices. Is there anything to be done to make the Eigen operation faster? Problem Details X : random 1000 x 50000 matrix Y : random 50000 x 300 matrix Timing experiments (on my late 2011 Macbook Pro) Using Matlab: X*Y takes ~1.3 sec Using Enthought Python: numpy.dot( X, Y) takes ~ 2.2 sec Using Eigen: X*Y takes ~2.7 sec Eigen Details You can get my Eigen code (as a MEX function): https://gist.github.com/michaelchughes