How to use min and max function in mex

5 visualizaciones (últimos 30 días)
A R
A R el 14 de Feb. de 2020
Respondida: Geoff Hayes el 14 de Feb. de 2020
Hi, I have a 1x256 double data, and i need to find the maximum and minimum value in mex file. I tried using min() and max(), and fmin() and fmax(), but i get errors like this
"incompatible type for argument 1 of 'fmin' b=fmin(data);"
"note: expected 'double' but argument is of type 'double *' extern double __cdecl fmin (double, double);"

Respuestas (1)

Geoff Hayes
Geoff Hayes el 14 de Feb. de 2020
A - The error message is telling you what is wrong
expected 'double' but argument is of type 'double *'extern double __cdecl fmin (double, double);
The min, max, fmin, and fmax functions expect inputs of type double (or float) but you are passing in a pointer to an array of doubles (or floats). You may need to write some code to loop over each element in the array (or perhaps you can use std::min or std::min_element if available).

Categorías

Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by