mex

Embedding Python in MATLAB

自古美人都是妖i 提交于 2019-12-02 20:13:31
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 have tried a number of ways to load the numpy libraries including In the python module (.py): from numpy import * With PyRun_SimpleString in the mex file: PyRun_SimpleString(“from numpy import *”); Calling numpy functions with Py_oBject_CallObject : pOut = PyObject_CallObject(pFunc, pArgs); Originally, I thought this may be a problem with embedding

Mex file building with Octave (issue with wrappers)

人走茶凉 提交于 2019-12-02 17:28:14
问题 I am currently porting some code from Matlab to Octave. Some of the functions of the Matlab code use the Piotr's Computer Vision Matlab Toolbox (here) that includes some mex files. In Matlab, everything is working like a charm but when I run my codes with Octave, it throws this error: error: 'imResampleMex' undefined near line 50 column 5 However all the internal paths within the toolbox should be good. I figured out that the way Matlab and Octave handle mex files is different and tried to

Launch one C++ application from another, and communicate with it

廉价感情. 提交于 2019-12-02 12:02:17
问题 I have a C++ (technically MATLAB mex) program, which I am planning to use to launch a stand-alone pure C++ slave program on my system. The master calling program may look something like the following: void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[]){ system ("path/to/slave/program"); } Once the slave is launched, I would then like to have a second mex program which will communicate with and send data to the slave program. The data sent will be in the form of large-ish

How to use dll generated by visual studio in another machine without visual studio installed?

我是研究僧i 提交于 2019-12-02 10:27:15
I have generated dynamic library in visual studio 2012. I want to use that library in another machine, but I don't want to install visual studio in remote machine. I have mex library and dll and I want to run a script which uses both libraries. When I run the script I got the following error. "Missing shared libraries: MSVCR110D.dll, MSVCP110D.dll" Where do I need to place those dll's inorder to run my script file in matlab. MSVCR110D.dll and MSVCP110D.dll are debug libraries. If your library requires them, then that means that your library was built in Debug mode, with all of the debug

Return values from a C++ MEX file to MATLAB

微笑、不失礼 提交于 2019-12-02 10:07:17
I am coding a MATLAB program that retrieves data from C++ code. To do so, I have created a MEX-file in MATLAB and a gateway mexFunction. Although the read value can be read in MATLAB, I cannot retrieve it to work with it. If this is unclear, I have quite the same problem as here ( How to return a float value from a mex function, and how to retrieve it from m-file? ) but I want to retrieve a value displayed by my C++ program. Here is my C++ code: #define _AFXDLL #define _tprintf mexPrintf #include "StdAfx.h" #include "704IO.h" #include "Test704.h" #include "mex.h" #ifdef _DEBUG #define new

Create a MATLAB MEX file for a C program

百般思念 提交于 2019-12-02 08:35:28
问题 I'm an experienced MATLAB user but totally new to C and MEX files. I have a complex program written in C that I need to call from within MATLAB. The program consists of a few dozen files in a folder, including one called main.c that processes inputs from the command line passes the results to other classes that do the actual calculations. Normally, to install this program from the command line, I would run ./configure, make at the UNIX command prompt. Then, to run the program, ./runMyProgram

Mex file building with Octave (issue with wrappers)

白昼怎懂夜的黑 提交于 2019-12-02 07:57:18
I am currently porting some code from Matlab to Octave. Some of the functions of the Matlab code use the Piotr's Computer Vision Matlab Toolbox ( here ) that includes some mex files. In Matlab, everything is working like a charm but when I run my codes with Octave, it throws this error: error: 'imResampleMex' undefined near line 50 column 5 However all the internal paths within the toolbox should be good. I figured out that the way Matlab and Octave handle mex files is different and tried to build one of the mex files from the C++ function within Octave like this: mkoctfile --mex imResampleMex

MATLAB crashes when it reaches mxSetPr in a mex file

落花浮王杯 提交于 2019-12-02 07:51:03
问题 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] =

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

筅森魡賤 提交于 2019-12-02 07:11:27
问题 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. I'm trying to run a Mex file using Armadillo from Matlab. It compiles fine using the command (truncated for short): mex -compatibleArrayDims -outdir +mx -L/home/john/.local/arma/lib -larmadillo -I/home

how to create a single float sparse matrix in mex files

非 Y 不嫁゛ 提交于 2019-12-02 06:00:46
问题 This Creating sparse matrix in MEX has a good example on mxCreateSparse . But this function return a double sparse matrix instead of single . If I want to return a single sparse matrix, what should I do ? Thanks ! 回答1: As @horchler suggested, you could use the undocumented function mxCreateSparseNumericMatrix . Example: singlesparse.c #include "mex.h" #include <string.h> /* memcpy */ /* undocumented function prototype */ EXTERN_C mxArray *mxCreateSparseNumericMatrix(mwSize m, mwSize n, mwSize