error line:- Index in position 2 exceeds array bounds. Index must not exceed 4.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
%svm
train=DF;
xdata =train;
TrainingSet=double(xdata);
GroupTrain=[1;1;1;1;1;1;1;1;1;1;2;2;3;3]
TestSet=double(QF);
u=unique(GroupTrain);
numClasses=length(u);
result = zeros(length(TestSet(:,1)),1);
%build models
for k=1:numClasses
%Vectorized statement that binarizes Group
%where 1 is the current class and 0 is all other classes
G1vAll=(GroupTrain==u(k));
G1vAll=reshape(G1vAll(1,14))
mdl(k) = fitcsvm('G1vAll','result');
end
%classify test cases
for j=1:size(TestSet,1)
for k=1:numClasses
if(classificationsvm(mdl(k),TestSet(j,:)))
break;
end
end
result(j) = k;
end
out=result
%
2 Commenti
Risposte (1)
Sandeep
il 26 Set 2023
Hi Saiprathyush reddy,
It is great to know that you are working with the Support Vector Machine classifier.
The error occurs in the line mdl(k) = fitcsvm('G1vAll','result'); because you are passing the strings 'G1vAll' and 'result' as arguments to the 'fitcsvm' function. However, the 'fitcsvm' function expects the actual data as input, not the string representation of variable names.
To fix this error, you should pass the actual data to the 'fitcsvm' function.
Hope you find it helpful.
0 Commenti
Vedere anche
Categorie
Scopri di più su Get Started with MATLAB in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!