Index in position 2 exceeds array bounds.

2 次查看(过去 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
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 CenterFile Exchange 中查找有关 Dimensionality Reduction and Feature Extraction 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by