This code does the following:
More details about the procedures:
Get a train data set X with its label vector l
Parameters selection
Randomly pick some observations from X and their corresponding labels l, and let's call the data set X_param
Make Ncv_param-fold cross validation to select the parameters c and gamma from X_param
At the end you get bestc and bestg for c and gamma respectively
Train the svm model modelSVM using the best parameters bestc and bestg
modelSVM = svmtrain(l, X, bestc, bestg)
Get a test data set X_test with its label vector l_test
Classification the test set
accuracy = svmclassify(l_test, X_test, modelSVM)
matlab code: demo_libsvm_test10.