Q:

How to get classification accuracy from confusion matrix using LIBSVM? 

Friends, Currently i am working in SVM classifier (5 fold cross validation) using LIBSVM.  Below i have the mentioned the code.  Totally, the data has 120 x 4 vectors with 3 classes.  Therefore, each fold, the trainData = 120 x 4, testData = 30 x 4.  The problem is, i have to get the classification accuracy from confusion matrix.  
I need answers for the following questions:

How to get the classification accuracy for each class from confusion matrix?? 
What is the need for probability estimates? 
What the term refers "predict the class with the highest probability"? 
I do not understand the result of "acc"??? 

Thanks in advance friends. 
The code is: 
load fisheriris                   %# Fisher Iris dataset
[~,~,labels] = unique(species);   %# labels: 1/2/3
data = zscore(meas);              %# scale features
numInst = size(data,1);
numLabels = max(labels);  
FISH =[];

numFolds = 5;
for jj=1:5% number of iterations

indices  = crossvalind('Kfold',labels,numFolds);       % K-Fold Validation
for ii = 1:numFolds 
test = (indices == ii); 
train = ~test

%# split training/testing
idx = randperm(numInst);
numTrain = 120; numTest = numInst - numTrain;
trainData = data(idx(1:numTrain),:);  testData = data(idx(numTrain+1:end),:);
trainLabel = labels(idx(1:numTrain)); testLabel = labels(idx(numTrain+1:end));

%# train one-against-all models
model = cell(numLabels,1);
for k=1:numLabels
model{k} = svmtrain(double(trainLabel==k), trainData, '-t 2 -c 1 -g 1 -b 1');
end

%# get probability estimates of test instances using each model
prob = zeros(numTest,numLabels);
for k=1:numLabels
[~,~,p] = svmpredict(double(testLabel==k), testData, model{k}, '-b 1');
prob(:,k) = p(:,model{k}.Label==1);    %# probability of class==k
end

%# predict the class with the highest probability
[~,pred] = max(prob,[],2);
acc = sum(pred == testLabel) ./ numel(testLabel)    %# accuracy
CM = confusionmat(testLabel, pred)                   %# confusion matrix
end
FISH =[FISH;(CM(1,1)/10)*100 (CM(2,2)/10)*100 (CM(3,3)/10)*100)      
end 

A:

1.  How to get the classification accuracy for each class from confusion matrix?? 
Your code handles the 3-class classification problem by transforming it into a one-vs-all problem.  More specifically, this code double(trainLabel==k) assigns label 1 in the samples that have the same label with k and label 0 on rest.  This is done for all classes inside the for loop and saves a models for each case.  Having actually a binary classification problem you can use the sensitivity and specificity measures.  Generaly, if you have negative and possitive labels, specificity measures how effectively a classifier identifies negative labels while sensitivity measures the effectiveness of a classifier to identify positive labels.  A good reference is here.    
2.  What is the need for probability estimates? 
LIBSVM has a parameter option (-b 1) to obtain a model with probability information and predict test data with probability estimates.  In the following code
%# get probability estimates of test instances using each model
prob = zeros(numTest,numLabels);
for k=1:numLabels
[~,~,p] = svmpredict(double(testLabel==k), testData, model{k}, '-b 1');
prob(:,k) = p(:,model{k}.Label==1);    %# probability of class==k
end

as the comment refers we get the probability of each object to bellong to a class.  This is obtained looping over the models and storing the probability of each sample to belong to the class specified by k variable.  This is done for all labels, numLabels. 
3.  What the term refers "predict the class with the highest probability"? 
Matrix prob has as many rows as the number of samples and number of columns as the number of labels.  In each row the number of column contain the probability a sample to bellong to the corresponding number of label.  For example, if in a row there are the following numbers 0.7 0.2 0.1 then the corresponding sample belongs to class 1.   
4.  I do not understand the result of "acc"??? 
acc is the classic accuracy metric: the total number of the correctly classified samples divided by the total number of samples.  This can also be obtained from the confusion matrix by summing the diagonal elements of the matrix and divide this number by the total number of frames in the matrix. 