Borrar filtros
Borrar filtros

Index in position 2 exceeds array bounds

1 visualización (últimos 30 días)
Muhammad Izz Irfan
Muhammad Izz Irfan el 28 de Dic. de 2020
Comentada: Jan el 30 de Dic. de 2020
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 comentario
Jan
Jan el 30 de Dic. de 2020
Please post a complete copy of the error message, such that the readers do not have to guess, where the problem occurs.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by