How to call C code generated with Matlab Coder from the statisticaL package R
이전 댓글 표시
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
Image Analyst
2014년 6월 26일
Get rid of all that, except for the first paragraph, and just attach your m-file with the paperclip icon.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Simulink Coder에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!