This code does the following:
More details about the procedures:
Get a train data set X with its label vector lParameters selectionRandomly pick some observations from X and their corresponding labels l, and let's call the data set X_paramMake Ncv_param-fold cross validation to select the parameters c and gamma from X_paramAt the end you get bestc and bestg for c and gamma respectivelyTrain the svm model modelSVM using the best parameters bestc and bestgmodelSVM = svmtrain(l, X, bestc, bestg)Get a test data set X_test with its label vector l_testClassification the test setaccuracy = svmclassify(l_test, X_test, modelSVM)matlab code: demo_libsvm_test10.