Index in position 2 exceeds array bounds
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
How i want to solve this kind of problem ? I got an error Index in position2 exceeds array bounds
Error in RunMCSVMClassifier4 (line 20)
result = zeros(length(Xtest(:,1)),1);
function [err,M] = RunMCSVMClassifier4(Xtrain,Ytrain,Xtest,Ytest)
u=unique(Ytrain);
numClasses=length(u);
result = zeros(length(Xtest(:,1)),1);
models=[];
for k=1:numClasses
G1vAll=double(Ytrain==u(k));
models{k} = fitcsvm(Xtrain,G1vAll,'Standardize',true,....
'KernelFunction','RBF','KernelScale','auto');
end
%classify test cases
for j=1:size(Xtest,1)
for k=1:numClasses
if(predict(models{k},Xtest(j,:)))
break;
end
end
result(j) = k;
end
err=1-(sum(Ytest==result)/length(result));
if(nargout>1)
M=confusionmat(Ytest,result);
end
end
1 commentaire
Jan
le 30 Déc 2020
Please post a complete copy of the error message, such that the readers do not have to guess, where the problem occurs.
Réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!