% lamexample.m - LAM example % (C) 2005 by Yu Hen Hu % created: 9/19/2005 % clear all; close all X=[1 2 -1;-1 1 1;1 0 1]'; Y=[-1 2;2 4;1 -3]'; disp('input vectors X are: '); disp(X); disp('corresponding outputs are: '); disp(Y); W=Y*X'; disp('weight matrix W = '); disp(W); newx=[-1 1 1]'; recally=W*newx; disp(['if now the input vector is: ' num2str(newx')]); disp(['then the recalled y = ' num2str(recally')]); clc; echo on % Now consider a different output such that if input is [1 2 -1]' % then the output will say it is the first vector: [1 0 0]' % if input is [-1 1 1]', the output will be [0 1 0]' % if input is [1 0 1]', the output will be [0 0 1]' Y1=eye(3); W1=Y1*X'; pause; % Now apply the input [-1 1 1]'; % the output will be: recally1=W1*newx, pause; % Suppose now the input is corrupted with noise: newx1=[-1 1 1]' + 0.05*randn(3,1), % The output will also be perturbed: recally2=W1*newx1, pause; % But by identifying the maximum output [tmp,idx]=max(recally2), % This way, we may retrieve the clean copy of the input by xclean=X(:,idx),