I have been trying to find the max value from an array. But I keep getting the following error. Please advise.
scores = [19212 56722 73336 44805 47268]
max(scores)
??? Index exceeds matrix dimensions.
I have been trying to find the max value from an array. But I keep getting the following error. Please advise.
scores = [19212 56722 73336 44805 47268]
max(scores)
??? Index exceeds matrix dimensions.
you probably have a variable called max
. Try
clear max
max(scores)
Have you defined an array called max ?
scores = [19212 56722 73336 44805 47268 ]
max(scores)
ans = 73336
If I define an array called max
max=[1:10]
max(scores)
??? Index exceeds matrix dimensions.
Check by using the which function
which max
max is a variable.
It should be
which max
built-in (C:\Program Files\MATLAB\R2009a\toolbox\matlab\datafun\@logical\max) % logical method
max()
function if you were curious enough to go looking.
– Li-aung Yip
Apr 11 '12 at 8:28
To get the indices of the maximal value: scores=1:10; find(scores == max(scores))
If you have two maximum values:
clear max
scores=10:-1:1;
scores=[scores 10];
find(scores == max(scores))
ans =
1 11
As you might guess max
return the max
of an array:
>> max(scores)
ans =
10