function linearplot11(data, classes, weights)
%Zobrazi XY graf dat a zobrazi rozhodovaci hranici pro linearni
%klasifikator.
% 
%Vstupni promenne:
% - data      - 2D data, souradnice bodu (pokud si funkce stezuje na
% neodpovidajici rozmery, zkuste data (pripadne i classes) transponovat
% - classes   - pro kazdy radek z dat indikace tridy (-1/+1)
% - weights   - vektor vah linearniho/nelinearniho klasifikatoru (posledni
% prvek je posun - bias)
% 
% Priklady pouziti:
% load('cv11-nonlinsep.mat')
% linearplot11(traindata, repmat([1 -1],1,50), [1 0.5 0.2 0.1 10 5])
% linearplot11(traindata, repmat([1 -1],1,50), [1 0.5 2])



x = min(data(:,1)):0.1:max(data(:,1));
y = min(data(:,2)):0.1:max(data(:,2));

xdata = zeros(length(x), length(y));
            
if (length(weights) == 3)
    for i = 1:length(x)
        z = [repmat(x(i), 1, length(y))', y', repmat(1, 1, length(y))']';
        xdata(i,:) = z' * weights';
    end
elseif (length(weights) == 6)
    for i = 1:length(x)
        z = [repmat(x(i), 1, length(y))', y', repmat(1, 1, length(y))']';
        z = [z(1,:); z(2,:); z(1,:) .* z(1,:); z(1,:) .* z(2,:); z(2,:) .* z(2,:); z(3, :)];
        xdata(i,:) = z' * weights';
    end    
else
    disp('Error - not original data nor dimension extended data.')
    return
end

zdata = zeros(size(xdata));
zdata(xdata > 0) =  1;
zdata(xdata < 0) = -1;

contour(x,y,zdata',1, 'k');
hold on
scatter(data(classes==-1,1), data(classes==-1,2), 'r');
scatter(data(classes==1,1), data(classes==1,2), 'b');
hold off