%% Example 4 (Same as Example 3, but uses a subroutine for Widrow-Hoff) %% First, set up the data and plot: T1=[1 1 1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 1 -1 -1]; T2=[-1 1 1 1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 1 -1]; G1=[1 1 1 -1 1 -1 -1 -1 1 1 1 -1 1 1 1 -1]; G2=[-1 1 1 1 -1 1 -1 -1 -1 1 1 1 -1 1 1 1]; F1=[1 1 1 -1 1 1 -1 -1 1 -1 -1 -1 1 -1 -1 -1]; F2=[-1 1 1 1 -1 1 1 -1 -1 1 -1 -1 -1 1 -1 -1]; gg=colormap(gray); gg=gg(end:-1:1,:); subplot(2,3,1) imagesc(T1) colormap(gg) subplot(2,3,2) imagesc(G1) subplot(2,3,3) imagesc(F1) subplot(2,3,4) imagesc(T2) subplot(2,3,5) imagesc(G2) subplot(2,3,6) imagesc(F2) %% Next, create the domain and targets: X=[T1(:) T2(:) G1(:) G2(:) F1(:) F2(:)]; T=[60 60 0 0 -60 -60]; alpha=0.03; %% Call our training function: [W,b,err]=wid_hoff1(X',T',alpha,10) % The matrix err is 10 x 6, we can plot mean(err') to see the mean error % on the 10 trials: figure; % Open a second figure plot(mean(err'))