?? testa.m
字號:
%% Project1 autoassociative memory%% Input x: the Matrix of the ten numbers%% Output ar: the output accuracy of the ten numbers %% meanar: the mean output accuracy of the ten numbers%% standard charactersfunction [ar,meanar]=testa(x)one=[-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; -1 1 1 1 -1];two=[-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 ; 1 1 1 1 1];three=[-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; -1 1 1 1 -1];four=[-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; -1 -1 -1 -1 1];five=[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; 1 1 1 1 -1];six=[-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; -1 1 1 1 -1];seven=[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; -1 1 -1 -1 -1];eight=[-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; -1 1 1 1 -1];nine=[-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; 1 1 1 1 -1];zero=[-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; -1 1 1 1 -1];s1=reshape(one,35,1); s2=reshape(two,35,1); s3=reshape(three,35,1); s4=reshape(four,35,1); s5=reshape(five,35,1);s6=reshape(six,35,1); s7=reshape(seven,35,1); s8=reshape(eight,35,1); s9=reshape(nine,35,1); s0=reshape(zero,35,1);T1=[s1,s2,s3,s4,s5,s6,s7,s8,s9,s0];wold=zeros(35,35); for i=1:10 z(:,:,i)=reshape(T1(:,i),7,5); wnew=wold+x(:,i)*x(:,i)'; wold=wnew; end for i=1:10 u(:,i)=wold*x(:,i); u(find(u>=1))=1; u(find(u<=-1))=-1; end for i=1:10 y(:,:,i)=reshape(u(:,i),7,5); %xx(:,:,i)=reshape(x(:,i),7,5); end figure for i=1:10 ar(:,i)=nnz(~round(y(:,:,i)-z(:,:,i)))/35; [m,n]=find(fliplr(y(:,:,i)')==1); [r,c]=find(fliplr(y(:,:,i)')~=1); subplot(2,5,i); plot(m,n,'rs', 'MarkerEdgeColor','k','MarkerFaceColor','y', 'MarkerSize',10) hold on plot(r,c,'gs', 'MarkerEdgeColor','k','MarkerFaceColor','k', 'MarkerSize',8) grid axis([0 6 0 8]) set(gca,'ytick',[0 2 4 6 8]) set(gca,'xtick',[0 2 4 6]) end meanar=mean(ar);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -