How to use the min() and max() functions?

68 views (last 30 days)
I am trying to use min() and max() to find the minimum and maximum values of a vector (attached to this post if you would like to try)
According to the Mathworks website, using minVal = min(FHNout); and maxVal = max(FHNout); should work.
However, when trying these commands, I get the following error:
??? Subscript indices must either be real positive integers or logicals.
Why am I getting this error and how do I fix it?
Thanks for your help

Accepted Answer

John D'Errico
John D'Errico on 31 Mar 2018
Edited: John D'Errico on 31 Mar 2018
If you want to use min or max, then don't name a variable with the name min, or max.
which min -all
which max -all
What does that tell you?
Never use variable names that conflict with a function name.
  1 Comment
EL890
EL890 on 31 Mar 2018
Thanks so much. That fixed the issue. There was another variable in my work space called min and max

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!