How to set output type manually in matlab coder

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.

Answers (1)

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.

Categories

Find more on MATLAB Coder in Help Center and File Exchange

Products

Release

R2020b

Asked:

on 12 Apr 2022

Answered:

on 13 Apr 2022

Community Treasure Hunt

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

Start Hunting!