function w = getWeightsFromSVM(svmStruct)
% Coded by Patryk Laurent (plaurent@me.com, laurent@jhu.edu)
% Computes weights from the SVM structure given by the bioinformatics toolbox
% You can then multiply these weights by your input vectors to obtain
% the value of the decision variable.

nSize = size(svmStruct.SupportVectors, 2);
if (numel(svmStruct.ScaleData) > 0)
    shift = svmStruct.ScaleData.shift;
    scale = svmStruct.ScaleData.scaleFactor;
    w = svmStruct.Alpha' * svmStruct.SupportVectors .* scale; 
    w(nSize+1) = svmStruct.Bias + w(1:nSize) * shift' ; 
else
    w = svmStruct.Alpha' * svmStruct.SupportVectors;
    w(nSize+1) = svmStruct.Bias ;
end
w = -w';


