%% Example 2: Pattern Classification, Batch Training. %% Set up the data (Y is actually the target matrix). N=100; %Number of points X1=0.8*randn(2,N)+repmat([2;2],1,N); X2=1.5*randn(2,N)+repmat([1;-2],1,N); X=[X1 X2]; X(3,:)=ones(1,2*N); Y=[repmat([1;0],1,N) repmat([0;1],1,N)]; %% Solve for the weights and biases. C=Y/X; %% Plotting routines: plot(X1(1,:),X1(2,:),'o',X2(1,:),X2(2,:),'x'); hold on n1=min(X(1,:));n2=max(X(1,:)); t=linspace(n1,n2); L1=(-C(1,1)*t+(-C(1,3)+0.5))./C(1,2); L2=(-C(2,1)*t+(-C(2,3)+0.5))./C(2,2); plot(t,L1,t,L2);