The min
and max
functions in MATLAB work on only integer values. How can I find the min and max of a double vector?
a = [2.1 3.4 5.6 7.6]
min(a)
returns to me:
Subscript indices must either be real positive integers or logicals.
The min
and max
functions in MATLAB work on only integer values. How can I find the min and max of a double vector?
a = [2.1 3.4 5.6 7.6]
min(a)
returns to me:
Subscript indices must either be real positive integers or logicals.
You've assigned min
as a variable name for an array somewhere in your code.
When you call min(a)
, MATLAB is trying to grab the indices [2.1,3.4,5.6,7.6]
from your array min
. To fix this problem, simply call the variable something else.
EDIT: And if you're running it outside of a function, clear min
and max
, as @Acorbe points out.
You need to clear min
and max
since they are assigned already and their variable counterparts hide the function names.
To use them as functions, do first
clear min
clear max