f



How to release a matrix created in matlab inside mex file.

Dear all.

I play around huge matrices with data and when I pass one of them to a mex file, I want to be able to release memory associated with it from inside the mex file. Is this possible?

For instance, when I do something like this, it violates memory when called from matlab.

Cheers,
Pete

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
	if (nrhs!=1)
	{
		mexPrintf(" - insufficient argument list!\n");
		return;
	}	
	
	mxArray* xVar=(mxArray*)prhs[0];
	mxDestroyArray(xVar);

	return;
}
0
Pete
10/17/2014 12:05:47 AM
comp.soft-sys.matlab 211266 articles. 24 followers. lunamoonmoon (257) is leader. Post Follow

0 Replies
1029 Views

Similar Articles

[PageSpeed] 17

Reply:

Similar Artilces:

adding some of the files from Matlab central to the offical Matlab releases?
I see some very useful files and commands at Matlab central, and wonder why Mathworks does not add these to the official Matlab release? This will make using these files/commands easier, so that, for example, when sending an .m file to someone, they do not have to go download some additional files from matlab central first to the code. Just for an example, there is the GUI layout manager toolbox http://www.mathworks.com/matlabcentral/fileexchange/27758-gui-layout-toolbox And the factorize() and inverse() commands in http://www.mathworks.com/matlabcentral/fileexchange/24119 ...

how to call matlab file to another matlab file
Hey friends, i am working on simulation of power system using matlab. for that i have written codes for generation side and line side separately. Now i want to use the result of generation file to line file....so how can i use the result of one file to another.... eg i have gen.m file from that i can get hourly gen data....now i want to compare that data to line.....and line modelling is done in separate file line.m so i want to call result of gen.m file to line.m file..... waiting for ur valuable suggestion thanks ...

Create (Matlab) object inside C/C++ and pass it to Matlab
I'm trying to create an object inside C++ and then pass it to Matlab via en= gPutVariable. It seems I can create a struct // Create a float array mxArray *acq_data =3D mxCreateNumericMatrix(0, 0, mxSINGLE_CLASS); float *data =3D (float *)mxCalloc(M*N, sizeof(float)); mxSetData(acq_data, data); mxSetM(acq_data, M); mxSetN(acq_data, N); // Convert to struct const char *fieldname =3D "data"; mxArray *acq_struct =3D mxCreateStructMatrix(1,1,1, &fieldname); mxSetField(acq_struct,i,"data",acq_data); // Convert to class ?? Does it work? if (j=3D=3D1...

mex files inside MATLAB WebServer
We are having trouble with a particular function inside our MATLAB WebServer application that uses a mex file. Is there a problem with mex files & the WebServer toolbox? ...

Creating Mex-files from MATLAB code
Could someone please give a link to a good tutorial explaining how MEX-files can be created from Matlab code? P.S. I have a function 'myfun.m' that calls 4 functions 'myfun1.m'-'myfun4.m' Thanks. "Liana" wrote in message <j8mqmv$98v$1@newscl01ah.mathworks.com>... > Could someone please give a link to a good tutorial explaining how MEX-files can be created from Matlab code? P.S. I have a function 'myfun.m' that calls 4 functions 'myfun1.m'-'myfun4.m' > > Thanks. 1) Why do you want to create a mex file from your m-...

MATLAB crashing with MEX file in function working well outside of MATLAB
Hi Everyone, I have an high level problem (I believe) that I will try to explain; My development platform is: 64bit Ubuntu 12.04 LTS and MATLAB 2013b with GCC/G++-4.7 library I am trying to create a MATLAB interface by coding a MexFunction using gigantic C++ library previously developed. For the tests I previously build and MexFunction only using and parsing XML files as inputs where paths are hardly defined within the function (for simplification and debugging), and I am not passing any input and output with *plhs and *prhs yet. My code includes MexFunction can be compiled with...

Access to multidimensional Matlab matrix in MEX file
Hello, I'm new to mex files and I'm trying to access specific cells in a multidimensional matrix. A(x,y,z) I think I understood the 2D example in the matlab help: [dimX, dimY] = size(A) A(x,y) in Matlab is projected to index(x + dimX*y) But how is the data organized for higher order matrices? Thank you for your help. Sincerely, Sarah If you have a rank N matrix with dimensions [x0,x1,...,xN-1], the element [y0,y1,...,yN-1] will be at index = y0+y1*x0+y2*x0*x1+...+yN-1*x0*x1*...*xN-2 so, 3 dimensions index [1,2,3] (zero-relative) of an XxYxZ matrix would be at 1+2*X+3*X*Y assum...

Is there a way to create MEX DLL for earlier version of Matlab on Matlab 2006a, or 2006b?
HI all, Is there a way to create MEX DLL for earlier version of Matlab on Matlab 2006a, or 2006b? Thanks On Fri, 13 Apr 2007 01:08:54 -0700, Mike wrote: > HI all, > > Is there a way to create MEX DLL for earlier version of Matlab on Matlab > 2006a, or 2006b? If you compile them with R2006a, they will work back to 7.0. If you use 2006b they will only work as far back as 2006a, because Mathworks made some incompatible changes. Dan > > Thanks "Dan Hensley" <somewhere@somewhere.withnospam> wrote in message news:pan.2007.04.13.13.45.55@somewhere....

DLL creating by Matlab for Matlab
I would like to know if it is possible to convert several M-files into one DLL with Matlab (by using mcc or mex or other functions) and use this DLL with Matlab. How can I do that? I could create DLL with mcc -l xxx.m but I can't use this DLL with Matlab (error: "??? The function, script or class xxx cannot be indexed using {} or . indexing.") I have a project on Matlab with just M-files and I want to give this project to someone who want to use it on Matlab too, but I don't want to give him the source M algorithms. Moreover, I don't want to have an executable....

Matlab doesn't create mex file
The .m function at the bottom works properly. However, when trying to make a mex file with the command mcc -x flowstJ the program gives the following error: --> "lcc -c -Zp8 -I"D:\MATLAB6p5\sys\lcc\include" -DMATLAB_MEX_FILE -noregistrylookup -Foflowstj.obj -ID:\MATLAB6p5\extern\include -ID:\MATLAB6p5\simulink\include -DNDEBUG flowstj.c" lcc preprocessor warning: flowstj.c:250 EOF inside comment Warning flowstj.c: 249 missing return value Error flowstj.c: 249 syntax error; found `end of input' expecting `}' 1 errors, 2 warnings D:\MATLAB6P5\BIN\WIN32\MEX...

Pass a 3d matrix from matlab to C mex file
please i need help how can i pass a 3d matrix from matlab to C mex file thanks Its the same as passing in a 2D matrix. You can get individual elements like: void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { double * pData; mwSize * pSize; mwSize nDims; double DesElement; nDims = mxGetNumberOfDimensions(prhs[0]); pSize = mxGetDimensions(prhs[0]); pData = mxGetPr(prhs[0]); //Then to get element at equivilent Matlab index (r,c,d) DesElement = pData[r-1 + (c-1)*pSize[0] + (d-1)*pSize[0] *pSize[1]]; } "Bavi b...

pass 3D Matrix from matlab to C mex- file
help please how can i pass 3d matrix from matlab to c using mex file thanks baavour@gmail.com wrote: > help please > > how can i pass 3d matrix from matlab to c > > using mex file This is a mailing list for the Python programming language. Please ask your question on the appropriate Matlab mailing list. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco ...

How can I create DLLs for use in MATLAB mex-file
Hello everybody, I tried to create a dll in Visual C++ 2008 and want to use it in a MATLAB mex-file. The problem is, that the linked reports "unresolved symbol" on my test function. Can anyone tell me what I need to do to use my own dlls? Regards, Hmp "hmp hmp" <hmp@hmp.de> wrote in message <h3viie$4pu$1@fred.mathworks.com>... > Hello everybody, > > I tried to create a dll in Visual C++ 2008 and want to use it in a MATLAB mex-file. > > The problem is, that the linked reports "unresolved symbol" on my test function. > > Can ...

Pass a 3d matrix from matlab to C mex file #2
please i need help how can i pass a 3d matrix from matlab to C mex file thanks ...

Web resources about - How to release a matrix created in matlab inside mex file. - comp.soft-sys.matlab

Press Release Rocket - News and Current Events
By Toi Williams on December 24, 2014 Workers at more than 1,400 Walmart stores across the nation are set to see their pay rise next year as ...

Press release - Wikipedia, the free encyclopedia
A press release , news release , media release , press statement or video release is a written or recorded communication directed at members ...

Apple releases tvOS 9.1.1 software update with Podcasts app for the new Apple TV
There’s a new software update awaiting Apple TV 4 owners as Apple released a small point update for all users today. tvOS 9.1.1 likely includes ...

Apple releases tvOS 9.1.1 with an official Podcasts app for the new Apple TV
Apple has just released tvOS 9.1.1 for owners of the fourth-generation Apple TV. If you own the new streaming device, download the software by ...

World’s most accurate Apple analyst drops major info on Apple’s early 2016 releases
The iPhone may be Apple's primary revenue driver, but the Mac over the past few years has remained a steady and perhaps surprising contributor ...

Young Thug reveals 'Slime Season 3' release date, shares "Top Notch," rumored to be on Kanye West's 'Swish' ...
... Thug is set to follow his Slime Season and Slime Season 2 mixtapes with the third installment, Slime Season 3, and he just revealed the release ...

KUO: Apple is going to release new MacBooks sooner than previously thought
KGI Securities analyst Ming-Chi Kuo has released a research note that predicts new, updated MacBook models are coming in the first half of 2016, ...

IPRA Releases 911 Calls Made By Quintonio LeGrier On Morning He Was Fatally Shot By Chicago Police Officer ...
CBS Local IPRA Releases 911 Calls Made By Quintonio LeGrier On Morning He Was Fatally Shot By Chicago Police Officer CBS Local (CBS) — The ...

Atari Vault to release 100 classic video games on Steam
Asteroids, Centipede and more fan favorites from the 1970s and 80s are getting new life

ISIS releases new video of Paris attackers
CNN ISIS releases new video of Paris attackers CNN (CNN) ISIS has released a gruesome new propaganda video that purports to show final messages ...

Resources last updated: 1/26/2016 10:00:18 AM