How to call C code generated with Matlab Coder from the statisticaL package R
Show older comments
Dear all,
I am generating C code from Matlab coder. I want to call the generated code from R (a statistical package). My preferred option for doing this would be to use the native R function ".C". This function requires that the variable types are explicitly declared within the .C function call. So the function call (from within R) would look something like this....
.C("pca_uev",x=as.double(x),y=as.double(x),u=as.double(u),e=as.double(e),v=as.double(v))
After generating the C code from Matlab, the entry point of the function looks like this:
void pca_uev(const emxArray_real_T *x, const emxArray_real_T *y, emxArray_real_T *u, double e_data[], int e_size[1], emxArray_real_T *v) { .....remainder of code..... }
Question is how to declare variables correctly to the Matlab generated C code. From within R, I only have the types "double", "single", "integer", etc... available. Matlab seems to define its own data structures somewhere/somehow. In the above problem, x and y (inputs) and u, e, v (outputs) would all be matrices.
I understand that C does not have a native data structure for matrix types. So it makes sense that Matlab generates a type for it. Declaring the matrix x as double from R would presumably pass it as a vector.
Does anyone know how to do the declaration correctly - or can point me to the right reference or documentation on this problem?
I attach the complete Matlab generated C code (for completeness).
Thanks,
Bart Mertens
1 Comment
Image Analyst
on 26 Jun 2014
Get rid of all that, except for the first paragraph, and just attach your m-file with the paperclip icon.
Accepted Answer
More Answers (0)
Categories
Find more on Simulink Coder in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!