Filter löschen
Filter löschen

Index in position 2 exceeds array bounds

1 Ansicht (letzte 30 Tage)
Muhammad Izz Irfan
Muhammad Izz Irfan am 28 Dez. 2020
Kommentiert: Jan am 30 Dez. 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 Kommentar
Jan
Jan am 30 Dez. 2020
Please post a complete copy of the error message, such that the readers do not have to guess, where the problem occurs.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by