%% Example 1: Pattern Classification, Batch Training. %% Construct the data (note the last row of ones) X=[2 1 -2 -1;2 -2 2 1]; X(3,:)=ones(1,4); Y=[-1 1 -1 1]; %% Solve for the weight matrix W directly using the slash command W=Y/X; %% Graphics commands to view the results: % Window size for graphics x1=-3;x2=3;y1=-3;y2=3; t=linspace(x1,x2); %This is the domain for the separating line below % Seperating line is ax+by+c=0 y=-(W(1)/W(2))*t-(W(3)/W(2)); plot(X(1,[1,3]),X(2,[1,3]),'^',X(1,[2,4]),X(2,[2,4]),'x'); %Original data hold on plot(t,y); axis([x1 x2 y1 y2]);