Program 2

Program 2 - % Define digits as vectors

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
% Define digits as vectors p0=[-1;1;1;1;1;-1;1;-1;-1;-1;-1;1;1;-1;-1; . .. -1;-1;1;1;-1;-1;-1;-1;1;-1;1;1;1;1;-1]; p1=[-1;-1;-1;-1;-1;-1;1;-1;-1;-1;-1;-1;1; . .. 1;1;1;1;1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1;-1]; p2=[1;-1;-1;-1;-1;-1;1;-1;-1;1;1;1;1;-1; . .. -1;1;-1;1;-1;1;1;-1;-1;1;-1;-1;-1;-1;-1;1]; p3=[1;-1;-1;-1;-1;1;1;-1;-1;-1;-1;1;1; . .. -1;-1;1;-1;1;1;-1;-1;1;-1;1;-1;1;1;1;1;-1]; p4=[1;1;1;1;-1;-1;-1;-1;-1;1;-1;-1;-1;-1; . .. -1;1;-1;-1;-1;-1;-1;1;-1;-1;1;1;1;1;1;1]; p5=[-1;-1;-1;-1;-1;-1;1;1;1;-1;-1;1;1;-1;1; . .. -1;-1;1;1;-1;1;-1;-1;1;1;-1;-1;1;1;-1]; p6=[1;1;1;1;1;1;1;-1;-1;1;-1;1;1;-1;-1;1; . .. -1;1;1;-1;-1;1;1;1;-1;-1;-1;-1;-1;-1]; % These vectors represent the columns of the table in the report correct2Hebb = zeros(1,6); correct2Pseudo = zeros(1,6); correct4Hebb = zeros(1,6); correct4Pseudo = zeros(1,6); correct6Hebb = zeros(1,6); correct6Pseudo = zeros(1,6); % Do once for Hebb Rule (rule = 1) and for Pseudoinverse Rule (rule = 2) for rule = 1:2 % For each iteration, include a new digit in input matrix for input = 1:6 if (input == 1) P = [p0 p1]; end if (input == 2) P = [p0 p1 p2]; end if (input == 3) P = [p0 p1 p2 p3]; end if (input == 4) P = [p0 p1 p2 p3 p4]; end if (input == 5) P = [p0 p1 p2 p3 p4 p5]; end if (input == 6) P = [p0 p1 p2 p3 p4 p5 p6];
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
end % Perform Hebb Rule if (rule == 1) W = P * P'; end % Perform Pseudoinverse Rule if (rule == 2) W = P * inv(P' * P) * P'; end % Repeat random pixel change (2, 4, or 6) 10 times
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

Program 2 - % Define digits as vectors

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online