Effacer les filtres
Effacer les filtres

How to set output type manually in matlab coder

13 vues (au cours des 30 derniers jours)
Alireza Tabatabaee
Alireza Tabatabaee le 12 Avr 2022
When I turn a simple matlab function that looks like y = wdn(x) into C code with matlab coder, the resulting C function looks like this:
void wdn(const float x[15400], emxArray_real_T *y)
How can I set y's type as float* ? I don't want to use emxArray_real_T because it is causing me problems when I try to use the code on a microcontroller.
I read somewhere that these structures are for dynamic memory allocation, however turning off dynamic memory allocation in matlab coder's settings did not help.

Réponses (1)

Denis Gurchenkov
Denis Gurchenkov le 13 Avr 2022
Hi Alireza,
The "emxArray_real_T" type indicates that the code generator does not know what is the maximum number of elements in "y". That is, it thinks that the number of elements in y may change from run to run, and it could not figure out an upper bound for it.
You could help the code generator to understand that y is bounded by using one of the techniques here:
If that does not help, maybe can attach the example you have (and the command line arguments you use) so that someone could take a closer look.
You also mentioned that the emxarray type creates an issue on the microcontroller. Why is so? That type is just a plain C struct type, and there is a header file that defines it, all you need to do is to make that header file available to your C compiler.

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by