The min function is not working, but the max function is. Help

Why is the min function working differently from the max function?
For example I have this 936x1 column and this is what happens:
min(matlabdate1982)
Error: Subscript indices must either be real positive integers or logicals.
max(matlabdate1982)
ans =
7.346826152497685e+05
Another example is if I have a simple vector: f=[1;2;3;4;5;6;7];
min(f)
ans =
35
24
56
30
36
27
17
max(f)
ans =
7
Why are these so different? Can anyone help me?

 採用された回答

Kelly Kearney
Kelly Kearney 2014 年 6 月 16 日
編集済み: Kelly Kearney 2014 年 6 月 16 日

5 投票

My guess is you created a variable named min
Type
which min -all
to check.

3 件のコメント

Shane
Shane 2014 年 6 月 16 日
It looks like I did crate a variable for that, short for minute. I still need that variable for something else. Should I change the name of that, which will then make min work again?
Kelly Kearney
Kelly Kearney 2014 年 6 月 16 日
Yes, rename the variable to something else and then delete the min variable. Variables in your workspace will always shadow functions of the same name, so it's good practice to avoid function-names when naming your variables.
You'll never be able to memorize all functions, but it seems the most common culprits are things like min, max, mean, sum, date, path, etc.
Star Strider
Star Strider 2014 年 6 月 16 日
One way to check that possibility (in the MATLAB Editor) is to right-click on the variable name, then click on ‘Help on Selection’ in the pop-up menu that appears. If the ‘Help’ window that appears says ‘No help found for ...’ you’re safe.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

質問済み:

2014 年 6 月 16 日

コメント済み:

2014 年 6 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by