In C++/mex file, will the changes in memory in C be automatically reflected in Matlab
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello, I am kind of new to the mex functions. If I use the mxGetData to get the pointer to the array and I change the value in the memory of that array, do I still need to make a copy of values using some mxfunctions and return it to matlab? Or I need to do nothing and the value in Matlab will automatically change?
In other words, if we pass values to cpp using mxFunctions, do they do a shadow copy or a deep copy?
To make the question clear, here is an example C code:
float * temp_data = (float*) mxGetData(prhs[0]);//at this time, temp_data[0] = 0
temp_data[0] = 1;
If I don't do anything to return the temp_data, will the value in matlab be changed?
Thank you.
1 comentario
Adam
el 7 de Ag. de 2014
I'm afraid I don't know the answer off-hand, though I assume if you already have your mex program setup you could verify one way or the other in a few seconds yourself?
Respuestas (0)
Ver también
Categorías
Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!