Updating variables in workspace from MEX functions
Mostrar comentarios más antiguos
In my current mex function, i need to update a couple of variables in the workspace(from where my function is called) from my mex function, for which i am currently trying to update one at a time...my current piece of code, which trying to do, looks like this:
mxArray *a_out_m;
int success;
static double *temp_ptr;
static double temp_val;
a_out_m = mexGetVariable("caller", "input_var");
temp_val = *mxGetPr(a_out_m);
temp_val = temp_val + (temp_val*10);
2 comentarios
jchaliss
el 17 de Jul. de 2013
James Tursa
el 17 de Jul. de 2013
So is this what you would like to do?
1) Pass an INPUT_T object to the mex function (for purposes of discussion suppose this variable is named V in the caller workspace)
2) Have the mex function update the input_3 property of V
3) Pass this updated object V to another c/c++ function AND also have that update reflected in the original caller workspace variable V
4) Pass some output from the c/c++ function back to MATLAB to plot.
You can use mxGetProperty and mxSetProperty to do this in a mex function, but it will only work reliably if V is not shared (i.e., you never did something like W = V at the caller workspace level).
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!