Filter löschen
Filter löschen

How to call Matlab functions from C S functions

1 Ansicht (letzte 30 Tage)
Remus Mihail Prunescu
Remus Mihail Prunescu am 16 Jul. 2012
Hi,
Is it possible to call matlab functions from C S functions? I would need to call fzero and I do not wish to create another C function with the algorithm.
Thanks. Remus.

Akzeptierte Antwort

Kaustubha Govind
Kaustubha Govind am 16 Jul. 2012
You can use mexCallMATLAB, but will need to create/destroy mxArrays as needed.
  3 Kommentare
Kaustubha Govind
Kaustubha Govind am 16 Jul. 2012
Please run the following command to see an example of how you can the copy the data from your real_T arrays into mxArrays:
edit([matlabroot '/extern/examples/refbook/arrayFillGetPr.c']);
Remus Mihail Prunescu
Remus Mihail Prunescu am 17 Jul. 2012
It works! Here's an example for a one input, one output matlab function:
mxArray *in[1];
mxArray *out[1];
double *pointer;
in[0] = mxCreateNumericMatrix(3, 1, mxDOUBLE_CLASS, mxREAL);
pointer = mxGetPr(in[0]);
pointer[0] = A_T;
pointer[1] = B_T;
pointer[2] = C_T;
mexCallMATLAB(1, out, 1, in, "myMatlabFun");
pointer = mxGetPr(out[0]);
return *pointer;

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Troubleshooting in MATLAB Compiler SDK finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by