function [Ypre_SVC model bestc bestg]= SVMclassify(XTst, XTrn, YTrn, gammaval, Cval)


bestacc = 0;
for p = 1 : length(gammaval)
    for q = 1 : length(Cval)
        gu = gammaval(p);  cu = Cval(q);
        cmd = [' -v 3 -c ',num2str(cu),' -g ',num2str(gu)];
        cg(p,q) = svmtrain(YTrn, XTrn, cmd);
        if cg(p,q) >= bestacc
            bestacc = cg(p,q);
            bestc = cu;
            bestg = gu;
        end
    end
end
cmd = [' -c ', num2str(bestc), ' -g ',  num2str(bestg) ];
model = svmtrain(YTrn, XTrn, cmd);
Ypre_SVC = svmpredict(ones(size(XTst,1),1), XTst, model);
