I am attempting to pass a matrix from a class in Matlab to a code in C. The code in C cannot be changed and requires a double* to be passed in as an argument. I am trying to use libpointer(…) to modify the matrix into something that can be passed to the C code through a calllib(…) function.
I cannot post all of the code because it is quite extensive. The function of the Matlab code reads:
function obj = set.RP(obj, vals) rho = vals{1}; pres = vals{2}; if strcmp(rho,'None') rho = obj.R; end if strcmp(pres, 'None') pres = obj.P; end disp(rho) disp(pres) idxptr = libpointer('doublePtr',[rho, pres]); disp(idxptr) calllib('canteraLib', 'thermo_set_RP', obj.thermo, idxptr)end
The function in the C code reads:
int thermo_set_RP(int n, double* vals) { try{ ThermoCabinet::item(n).setState_RP(vals[0], vals[1]); return 0; } catch (...) { return handleAllExceptions(-1, ERR); } }
Thank you for your time
-Emil
Best Answer