Index exceeds matrix dimensions when finding max value

前端 未结 3 1216
不思量自难忘°
不思量自难忘° 2020-12-12 02:40

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                


        
3条回答
  •  庸人自扰
    2020-12-12 03:38

    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
    

提交回复
热议问题