# Hyperplane equation in SVM using Matlab

I want to get a equation of hyperplane in SVM classifier using Matlab in the case of linear separable data which is the easiest case. Actually I do not want to use Kernel function. Is there any way to find the equation of hyperplane in matlab?

## 1 Answer

All you need can be computed from kernel and support vectors. Matlab stores them in svmStruct. Just call the svmStrain function with autscale on false.

% parameters from svmStruct
w1 = dot(svmStruct.Alpha, svmStruct.SupportVectors(:,1));
w2 = dot(svmStruct.Alpha, svmStruct.SupportVectors(:,2));
bias = svmStruct.Bias;

% y = a*x + b
a = -w1/w2;
b = -svmStruct.Bias/w2;


See also:

https://de.mathworks.com/matlabcentral/newsreader/view_thread/276146

https://stackoverflow.com/questions/26549714/hyperplane-in-svm-classifier

• thank you very much for your help. i was wondering if you introduce me a data set which is linearly separable. – pardis Nov 14 '16 at 5:46
• i don't know a public (large) data set that is linearly separable. But there are many simple ones, like the Fisher Iris Data Set. It's included in matlab: load fisheriris gscatter(meas(:,1), meas(:,2), species,'rgb','osd'); xlabel('Sepal length'); ylabel('Sepal width'); N = size(meas,1); – hh32 Nov 14 '16 at 7:28
• thank you so much. However i need large data set for my research. – pardis Nov 15 '16 at 4:13
• Then i suggest you take a look at kaggle.com. There are a lot of large datasets you can use. – hh32 Nov 15 '16 at 8:59