how to find minimum value of output corresponds to which input values in a loop/nested loop ? Error i am getting is Index exceeds the number of array elements.
이전 댓글 표시
i want to find for what value of c and what value of hh , the genError is minimum. The error i am getting is Index exceeds the number of array elements. Index must not exceed 1.
load fisheriris
X = meas;
Y = species;
TTT=0;
for c=[0.05 0.1]
for hh=[0.1 1]
TTT=TTT+1;
t = templateSVM('Standardize',true,'KernelFunction','gaussian','kernelscale',c,'boxconstraint',hh);
Mdl = fitcecoc(X,Y,'Learners',t,'FitPosterior',true,...
'ClassNames',{'setosa','versicolor','virginica'},...
'Verbose',2);
CVMdl = crossval(Mdl);
genError(TTT) = kfoldLoss(CVMdl);
end
end
[mingenaratederror min_index] = min(genError);
c_kscale = c(min_index); % get the corresponding value from the c array
hh_boxcon = hh(min_index); % get the corresponding value from the hh array
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!