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 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!