Index in position 2 exceeds array bounds.
1 回表示 (過去 30 日間)
古いコメントを表示
[ciri_latihZ,muZ,sigmaZ] = zscore(ciri_latih);
% pca
[coeff,score_latih,latent,tsquared,explained] = pca(ciri_latihZ);
% inisialisasi variabel kelas_latih
kelas_latih = cell(jumlah_file,1);
% mengisi nama2 sayur pada variabel kelas_latih
for k=1:300
kelas_latih{k} = 'Angry';
end
for k=301:600
kelas_latih{k} = 'Disgust';
end
for k=601:900
kelas_latih{k} = 'Fear';
end
for k=901:1200
kelas_latih{k} = 'Happy';
end
for k=1201:1500
kelas_latih{k} = 'Neutral';
end
for k=1501:1800
kelas_latih{k} = 'Sad';
end
for k=1801:2100
kelas_latih{k} = 'Surprise';
end
% ekstrak PC1 & PC2
PC1 = score_latih(:,1);
PC2 = score_latih(:,2);
PC3 = score_latih(:,3);
PC4 = score_latih(:,4);
PC5 = score_latih(:,5);
% klasifikasi menggunakan knn
Mdl = fitcecoc([PC1,PC2,PC3,PC4,PC5],kelas_latih);
i got some error on line 82 at "PC1 = score_latih(:,1);" it says Index in position 2 exceeds array bounds. and i don't know to solve it, and the program not get that error before
1 件のコメント
Walter Roberson
2021 年 8 月 31 日
You could get that error if ciri_latih is empty.
For example it might be a global variable that you did not initialize.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!