error line:- Index in position 2 exceeds array bounds. Index must not exceed 4.
1 回表示 (過去 30 日間)
古いコメントを表示
%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
%
回答 (1 件)
Sandeep
2023 年 9 月 26 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!