% hw10.m % Linear Associative Memory (HW #10) % author: G. Dempsey, Bradley University % January 27, 1998 clear % clear variables before starting % define characters using a 5x5 matrix % For ANN training use key vectors (column vectors) with length 25 c1=[1 1 1 1 1 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0]'; % T c2=[0 1 1 1 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 1 1 0]'; % I c3=[1 1 1 1 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 1 1 1 1]'; % O c4=[1 1 1 1 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 1 1 1 1]'; % Z disp('press any key to display input characters') pause char1=[c1(1:5)';c1(6:10)';c1(11:15)';c1(16:20)';c1(21:25)'] char2=[c2(1:5)';c2(6:10)';c2(11:15)';c2(16:20)';c2(21:25)'] char3=[c3(1:5)';c3(6:10)';c3(11:15)';c3(16:20)';c3(21:25)'] char4=[c4(1:5)';c4(6:10)';c4(11:15)';c4(16:20)';c4(21:25)'] % build input Pattern Matrix A=[c1 c2 c3 c4]; % your code here % test code follows disp('press any key to display ANN output characters') pause achar1=[b(1:5,1)';b(6:10,1)';b(11:15,1)';b(16:20,1)';b(21:25,1)'] achar2=[b(1:5,2)';b(6:10,2)';b(11:15,2)';b(16:20,2)';b(21:25,2)'] achar3=[b(1:5,3)';b(6:10,3)';b(11:15,3)';b(16:20,3)';b(21:25,3)'] achar4=[b(1:5,4)';b(6:10,4)';b(11:15,4)';b(16:20,4)';b(21:25,4)'] disp('press any key to display ANN output characters after "rounding"') pause round(achar1) round(achar2) round(achar3) round(achar4) % create test patterns- degraded inputs % test 1: degraded T dc1=[0.3 1 1 1 0.3 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0]'; % T out=W*dc1; dchar1=[out(1:5)';out(6:10)';out(11:15)';out(16:20)';out(21:25)'] round(dchar1) % test 2: degraded T dc2=[0.3 1 1 1 0.3 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.2 1 0.2 0]'; % T out=W*dc2; dchar2=[out(1:5)';out(6:10)';out(11:15)';out(16:20)';out(21:25)'] round(dchar2)