MATLAB Answers

How to use min and max function in mex

4 ビュー (過去 30 日間)
A R
A R 2020 年 2 月 14 日
回答済み: Geoff Hayes 2020 年 2 月 14 日
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);"

  0 件のコメント

サインイン to comment.

回答 (1 件)

Geoff Hayes
Geoff Hayes 2020 年 2 月 14 日
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).

  0 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。

タグ


Translated by