⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testa.m

📁 使用autoassociative memory对阿拉伯数字进行识别,并画出最后结果
💻 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 + -