2012-04-11 88 views

回答

7

你有一個變量叫做max。儘量

clear max 
max(scores) 
+0

非常感謝。那就是訣竅。顯然我有一些其他變量「max」我的工作區。 – theIronGiant 2012-04-11 08:06:45

-1

要獲得的最大值的索引: 分數= 1:10; 發現(成績== MAX(分數))

如果你有兩個極大值:

clear max 
scores=10:-1:1; 
scores=[scores 10]; 
find(scores == max(scores)) 

ans = 

    1 11 

正如你可能已經猜到max返回數組的max:大概

>> max(scores) 

ans = 

    10 
9

是否定義數組稱爲最大

scores = [19212  56722  73336  44805  47268 ] 

max(scores) 

ans = 73336 

如果我通過使用該功能

which max 

max is a variable. 

定義名爲最大

max=[1:10] 

max(scores) 

??? Index exceeds matrix dimensions. 

檢查陣列應當

which max 

built-in (C:\Program Files\MATLAB\R2009a\toolbox\matlab\datafun\@logical\max) % logical method 
+0

什麼是「內置的(C:\ Program Files \ MATLAB \ R2009a \ toolbox \ matlab \ datafun \ @logical \ max)%邏輯方法」是什麼意思? – theIronGiant 2012-04-11 08:11:21

+0

@theIronGiant:「Built-in」是「內置函數」的縮寫,與變量相反,或者可能來自非標準工具箱的函數。給出的文件路徑是你可以找到MATLAB的'max()'函數的實現,如果你足夠好奇的話可以去看看。 – 2012-04-11 08:28:01

+0

「內置位」表示它是一個本地MATLAB函數,路徑名只是表明它所在的位置,這是一個版本2009a安裝在Windows機器上,您的設置可能有不同的版本或位置。 – Adrian 2012-04-11 08:28:07

相關問題