Your code isn't close to working, there seem to be many conceptual issues you seem to be missing. I'm going to assume that you understand that:
- The iris data (see linked question) is 4-dimensional. A linear classifier in this space is a hyperplane in 4 dimensions and you can't plot a 4-dimensional function in a 2-d plane.
- The result of plotting a one-vs-all classifier for 3 classes are three hyperplanes
- It makes no sense to plot the result of 10 fold cross validation per se as there is no one plot-able result, you can plot every intermediate result but you're far away being able to accomplish that.
Still I think there is a real question here. I'm going to take two dimensions of the iris data and plot the separating hyperplanes (lines, in this case). When you have the linked code, all you need to do is the following:
- Select two dimensions, in my case I selected dimensions 3 and 4 of the iris data.
- Split the data into two, one part to train and one part to test.
- Do a little bit of math and plot the points and lines.
This is the code:
S = load('fisheriris');
data = zscore(S.meas);
data = data(:,3:4);
labels = grp2idx(S.species);
opts = '-s 0 -t 2 -c 1 -g 0.25'; %# libsvm training options
indices = crossvalidation(labels, 2);
testIdx = (indices == 1); trainIdx = ~testIdx;
mdl = libsvmtrain_ova(labels(trainIdx), data(trainIdx,:), opts);
figure(1);
numlabels = numel(unique(labels));
testlabels = labels(testIdx);
testdata = data(testIdx,:);
style = {'b+','r+','g+'};
stylel = {'b-','r-','g-'};
for i=1:numlabels,
plot(testdata(find(testlabels==i),1),testdata(find(testlabels==i),2),style{i});
hold on;
w = mdl.models{i}.SVs' * mdl.models{i}.sv_coef;
b = -mdl.models{i}.rho;
x = -2:0.1:2
y = -(w(1)/w(2))*x - (b/w(2));
plot(x,y,stylel{i});
end
grid on;
hold off;
and this is the plot:

each colored line should split points of said color from all other colors. Observe that the lines were obtained by training and the points come from testing data on which we did not train.