Why do I get "Array indices must be positive integers or logical values" error ?

9 ビュー (過去 30 日間)
gbg
gbg 2022 年 7 月 11 日
編集済み: Walter Roberson 2024 年 9 月 6 日
Plot_X = 0:0.01:1
Per = quantile(SUSC,1:-0.01:0)
for i = 1:101
if i <101
Plot_Y(i) = sum(CAT(SUSC>=Per(100-i))) / sum(CAT,'all')
else
Plot_Y(i) = sum(CAT(SUSC>=0)) / sum(CAT,'all')
end
end
AUC= round(100*trapz(Plot_X,Plot_Y),1)
the error is in the line 7
Plot_Y(i) = sum(CAT(SUSC>=Per(100-i))) / sum(CAT,'all')

回答 (1 件)

Voss
Voss 2024 年 9 月 5 日
When i is 100, Per(100-i) is Per(0), which causes the error since 0 is not a valid index in MATLAB.

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by