mex

MATLAB R2016b - MEX fails to compile C++ code

不想你离开。 提交于 2019-12-13 03:08:03
问题 My last post was cluttered with lots of information. Part of it was this problem, which hopefully on its own with more info will make more sense. I am attempting to use mex in MATLAB R2016b to compile C++03 code on Windows. When I try to do so, I get the following errors: Error using mex cpp_mexapi_version.o: In function `mexfilerequiredapiversion': C:/Progra~1/MATLAB/R2016b/extern/version/cpp_mexapi_version.cpp:4: multiple definition of `mexfilerequiredapiversion' C:\Users\myName\AppData

Save a variable (float *) to plhs

人走茶凉 提交于 2019-12-13 03:01:53
问题 I have a code.But I do not know how to save the output(point *). That is I try to save float * out to plhs . The result printed is right. Is there any available example since I did not find a suitable one. Thanks for the answer. I do not have any error. But the result printed is right. But in Matlab, out is all zeros. I initialize out are all zeros. But After I call pointwise_search, out is no change. The problem is solved if I use out = pointwise_search(q,p,num_thres,x,len). #include "mex.h"

Reading .mat file from C: Can read variable ; but cannot return PROPERLY

∥☆過路亽.° 提交于 2019-12-13 01:37:25
问题 I am trying to use MATLAB-API to read .mat file using C (NOT C++). This is MATLAB code which would create sort of .mat file I want: A = [[1 2 3]; [5 7 1]; [3 5 9]]; B = [[2 4];[5 7]]; Creator = 'DKumar'; nFilters = 2; Filters{1} = [[-1.0 -1.0 -1.0]; [-1.0 8 -1.0]; [-1.0 -1.0 -1.0]]; Filters{2} = 2.0*[[-1.0 -1.0 -1.0]; [-1.0 8 -1.0]; [-1.0 -1.0 -1.0]]; cd('/home/dkumar/CPP_ExampleCodes_DKU/Read_mat_File'); save('Test_FILE.mat', 'A', 'B', 'Creator', 'nFilters', 'Filters'); Please notice that I

Matlab's 'run and time' crashes with mex file

99封情书 提交于 2019-12-13 00:16:49
问题 I am using glmnet library within my codebase in Matlab without problems during normal operation. However the moment I use Matlab's 'run and time' feature to analyse performance of my codebase, Matlab throws an access violation. The Mex file is the one that is shipped with the package. Is there a fundamental incompatibility of mex files and 'run and time', or do Mex files have to be strictly written to conform to 'run and time' runtime standards (perhaps to do with memory allocation

Error building MEX-files (MATLAB 2012a) on Kubuntu '/usr/bin/ld: cannot find -lstdc++'

偶尔善良 提交于 2019-12-12 21:24:30
问题 I'm trying to build a C program on Matlab 2012a, through the command: mex mat_trans2.c And I'm getting this error: /usr/bin/ld: cannot find -lstdc++ collect2: ld returned 1 exit status mex: link of ' "mat_trans2.mexa64"' failed. Error using mex (line 206) Unable to complete successfully. Some time ago I was able to build .c files, I don't know what is happening now! Maybe something has changed after a system upgrade on my Kubuntu 12.04 64 bit. Is there someone who know how to solve this?

MATLAB: MEX matrix division gives different result than m-file

陌路散爱 提交于 2019-12-12 18:41:43
问题 I've used MATLAB's coder tool to create a MEX version of the matrix exponential function, to be used in another set of functions. The issue is, the MEX version gives different results than the original m-file. After debugging it, I believe that the reason this is, is because the MEX file and the m-file do not do matrix division (\) the same. Or the MEX file has issues with it in the first place. All the variables leading up to the line where the matrix division occurs are equivalent on both

using integer arrays on mex

两盒软妹~` 提交于 2019-12-12 17:15:43
问题 I want to pass an integer array from MATLAB to C. I've tried using the type uint64_T but it keeps crashing. Getting a double pointer using mxGetPr() works fine, but I need to typecast the content into an integer and doing so in every iteration might be slow. I've tried this in the mexFunction: uint64_T *l; l= (uint64_T *)mxGetData(prhs[1]); The function calling this variable is of this form: void XAction( const double *v, const uint64_T *l, double *w) { for (j=c; j; j--) for (i=r-1; i; i--) w

Matlab mex “Missing dependent shared libraries”

本秂侑毒 提交于 2019-12-12 15:31:47
问题 I have a couple mex files I'm creating in Matlab 2017a. When I compile them with Visual Studio C++ 2017, they run fine on my computer. However, when I attempt to use them on another computer, I get an error that says Error using mfss_mex.filter_uni Invalid MEX-file 'path_to_mex_file\mexfile.mexw64': Missing dependent shared libraries: 'MSVCP140.dll' required by 'path_to_mex_file\mexfile.mexw64' 'VCRUNTIME140.dll' required by 'path_to_mex_file\mexfile.mexw64' I think I could resolve this by

Getting Matlab's mex to work with xcode 4.4 on Mountain Lion

一个人想着一个人 提交于 2019-12-12 14:56:34
问题 I recently bought a new computer that came with Mountain Lion (OS 10.8). I'd like to start working with mex files on this machine, but I'm having a hard time getting 'mex -setup' to find any compilers. Specs: Mountain Lion 10.8 Matlab 2012a XCode 4.4 I noticed that matlab has released a patch for XCode 4.2, and 4.3. I also realize that XCode 4.4 (and Mountain lion, for that matter) is not officially supported by Matlab. As far as I can tell, there is not a way to install 4.3 on Mountain Lion.

Avoid copying an array when using mexCallMATLAB

只谈情不闲聊 提交于 2019-12-12 14:43:34
问题 I have written a mex file for MATLAB. It calls MATLAB pinv function to calculate the Moore Penrose pseudoinverse. I named this function my_pinv . my_pinv gets an array and returns its pseudoinverse, exactly similar to pinv : A = magic(8); A = A(:,1:6) b = 260*ones(8,1) x = my_pinv(A)*b In the mex file, however, I have to copy the values of the input array to be able to use mexCallMATLAB . Here is the content of my_pinv.cpp : #include <matrix.h> #include <mex.h> #include <string.h> void