mex

MATLAB crashes when it reaches mxSetPr in a mex file

╄→尐↘猪︶ㄣ 提交于 2019-12-02 05:24:50
I am writing a function within in a mex file which calls a MATLAB function. Unfortunately, when it comes to mxSetPr , MATLAB crashes and does not proceed further. Could someone kindly tell me how I can fix this? void myconv2( double * Ain , double *Aout, int AnRows , int AnCols, double* kernel, int kernelnRows, int kernelnCols ) { mxArray *rhs[3], *lhs[1]; rhs[0] = mxCreateNumericMatrix( 0, 0, mxDOUBLE_CLASS, mxREAL ); rhs[1] = mxCreateNumericMatrix( 0, 0, mxDOUBLE_CLASS, mxREAL ); rhs[2] = mxCreateString ( "same" ); mxSetPr( rhs[0], Ain ); mxSetM ( rhs[0], AnRows ); mxSetN ( rhs[0], AnCols );

Mex compiling on 64 bit linux - /usr/bin/ld: cannot find -lstdc++

亡梦爱人 提交于 2019-12-02 04:26:36
Okay I am trying to compile a mex file on 64 bit linux, ubuntu to be precise with Matlab 2013a. First it gave a error that it could not find GLIBCXX_3.4.15 . Which was not part of the /usr/local/MATLAB/R2013a/sys/os/glnxa64/libstdc++.so.6 . I found this thread /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.15' not found and succesfully created a symbolic link ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.17 libstdc++.so.6 in /usr/local/MATLAB/R2013a/sys/os/glnxa64 Now I tried to compile again and now I get /usr/bin/ld: cannot find -lstdc++ collect2: error: ld returned 1 exit status This is

Accessing MATLAB's unicode strings from C

送分小仙女□ 提交于 2019-12-02 04:03:33
问题 How can I access the underlying unicode data of MATLAB strings through the MATLAB Engine or MEX C interfaces? Here's an example. Let's put unicode characters in a UTF-8 encoded file test.txt, then read it as fid=fopen('test.txt','r','l','UTF-8'); s=fscanf(fid, '%s') in MATLAB. Now if I first do feature('DefaultCharacterSet', 'UTF-8') , then from C engEvalString(ep, "s") , then as output I get back the text from the file as UTF-8. This proves that MATLAB stores it as unicode internally.

Building a MATLAB mex file in Visual Studio gives “LNK2019 unresolved external symbol _mexPrintf referenced in function mexFunction”?

ε祈祈猫儿з 提交于 2019-12-02 03:27:40
问题 I'm using Visual Studio 2012 x64 to build and debug a MATLAB 2014a x64 mex file directly (without using the mex command in MATLAB). I followed the instructions in this question to set up a Visual Studio project named test1 . I followed this tutorial to write a simple mex file, test1.cpp : #include <math.h> #include <matrix.h> #include <mex.h> void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { mexPrintf("Hello World!\n"); } Building this solution gives me this

Matlab Mex Socket Wrapper Library

烂漫一生 提交于 2019-12-02 02:37:47
Have anybody written a POSIX socket wrapping library for MATLAB using Mex? I basically want to open, write and read. Both sync and async alternatives would be nice. My main target platform is Linux. I know Mex and I know POSIX sockets. I just want to make certain that nobody else has done this already?. Amro If you want to work with sockets, you have two options: 1) use Java capabilities from inside MATLAB (see this answer here on SO for a quick example): TCP/IP Socket Communications in MATLAB TCP/IP Socket Communications in MATLAB using Java Classes 2) use C MEX-wrappers: msocket TCP/UDP/IP

Using mxGetPr vs mxGetData

不想你离开。 提交于 2019-12-02 01:49:20
问题 I am trying to write a simple mex function. I have an integer input which is the number of my objects. When I compile myMEX_1.cpp and call it by MATLAB with any input value, I always get: Number of Requested Objects := 0 But the myMEX_2.cpp works fine and show the number inputted from MATLAB command window. Where is the my mistake in myMEX_1.cpp ? My enviroment: MATLAB R2013a and Microsoft SDK 7.1 compiler. // myMEX_1.cpp #include "mex.h" void mexFunction(int nlhs, mxArray *plhs[], int nrhs,

Building a MATLAB mex file in Visual Studio gives “LNK2019 unresolved external symbol _mexPrintf referenced in function mexFunction”?

▼魔方 西西 提交于 2019-12-02 01:05:24
I'm using Visual Studio 2012 x64 to build and debug a MATLAB 2014a x64 mex file directly (without using the mex command in MATLAB). I followed the instructions in this question to set up a Visual Studio project named test1 . I followed this tutorial to write a simple mex file, test1.cpp : #include <math.h> #include <matrix.h> #include <mex.h> void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { mexPrintf("Hello World!\n"); } Building this solution gives me this message: > 1>------ Build started: Project: test1, Configuration: Debug Win32 > ------ 1> Creating library C

From .mexglx to .mex

柔情痞子 提交于 2019-12-02 00:26:45
问题 I've been given a Matlab program that uses an external C function. I only have the compiled version of this external function, and the extension is .mexglx . From what I have already red, it seems that this extension is the mex-file version compiled with linux. I run matlab under windows XP, and my problem is that my Matlab is not able to read the .mexglx extension. So my question is: is there any mean to change a file with the .mexglx extension to a .mex? Because for the moment I do not have

mex doesn't recognize inline

懵懂的女人 提交于 2019-12-02 00:15:48
问题 I'm trying to compile a matlab wrapper for libdc1394 which is a library for firewire cameras. I get a strange error involving some inline functions in a header file. I'm working on ubuntu 12.04 with gcc-4.6. I've compiled other mex files with success. This wrapper was also difficult to compile in mac. /usr/local/MATLAB/R2012b//bin/mex dc1394mex.c `pkg-config --libs --cflags libdc1394-2` -o dc1394.mexa64 Warning: You are using gcc version "4.6.3-1ubuntu5)". The version currently supported with

Using mxGetPr vs mxGetData

佐手、 提交于 2019-12-01 23:40:40
I am trying to write a simple mex function. I have an integer input which is the number of my objects. When I compile myMEX_1.cpp and call it by MATLAB with any input value, I always get: Number of Requested Objects := 0 But the myMEX_2.cpp works fine and show the number inputted from MATLAB command window. Where is the my mistake in myMEX_1.cpp ? My enviroment: MATLAB R2013a and Microsoft SDK 7.1 compiler. // myMEX_1.cpp #include "mex.h" void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { char str11[100]; unsigned short frameCount; //unsigned short *frameCountPtr;