?? nnd15os.m
字號:
function nnd15os(cmd,arg1,arg2,arg3)
%NND15OS Unsupervised Hebb demonstration.
%
% This demonstration requires either the MININNET functions
% on the NND disk or the Neural Network Toolbox.
% $Revision: 1.7 $
% Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc.
% First Version, 8-31-95.
%==================================================================
% CONSTANTS
me = 'nnd15os';
Fs = 8192;
pause1 = 0.7;
pause2 = 0.1;
% DEFAULTS
if nargin == 0, cmd = ''; else cmd = lower(cmd); end
% FIND WINDOW IF IT EXISTS
fig = nndfgflg(me);
if length(get(fig,'children')) == 0, fig = 0; end
% GET WINDOW DATA IF IT EXISTS
if fig
H = get(fig,'userdata');
fig_axis = H(1); % window axis
desc_text = H(2); % handle to first line of text sequence
lines = H(3:4); % belt circle lines
fruit_indicator = H(5); % fruit entrance indicator
top_indicator = H(6); % top exit indicator
bottom_indicator = H(7); % bottom exit indicator;
sounds = H(8:15); % pointers to sounds
angle_ptr = H(16); % angle (deg) of lines in conveyer ends
fruit_ptr = H(17); % pointer to fruit shape
arrows = H(21:22); % handles to arrows
rb1 = H(23); % Working radio button
rb2 = H(24); % Not working radio button
cross = H(25); % Not working cross
p1_ptr = H(26); % Input #1
p2_ptr = H(27); % Input #2
a_ptr = H(28); % Output
W2_ptr = H(29); % Weights #2
p1_box1 = H(30);
p1_text1 = H(31);
p1_box2 = H(32);
p1_text2 = H(33);
p1_box3 = H(34);
p1_text3 = H(35);
p2_box = H(36);
p2_text = H(37);
a_box1 = H(38);
a_text1 = H(39);
a_box2 = H(40);
a_text2 = H(41);
a_box3 = H(42);
a_text3 = H(43);
go_button = H(44);
mode_ptr = H(45);
W2_box1 = H(46);
W2_text1 = H(47);
W2_box2 = H(48);
W2_text2 = H(49);
W2_box3 = H(50);
W2_text3 = H(51);
mode = get(mode_ptr,'userdata');
end
%==================================================================
% Activate the window.
%
% ME() or ME('')
%==================================================================
if strcmp(cmd,'')
if fig
figure(fig)
set(fig,'visible','on')
else
feval(me,'init')
end
%==================================================================
% Close the window.
%
% ME() or ME('')
%==================================================================
elseif strcmp(cmd,'close') & (fig)
delete(fig)
%==================================================================
% Initialize the window.
%
% ME('init')
%==================================================================
elseif strcmp(cmd,'init') & (~fig)
% CHECK FOR TRANSFER FUNCTIONS
% ODJ 12/23/07 Check for NN Toolbox removed
%if ~nnfexist(me), return, end
% NEW DEMO FIGURE
fig = nndemof2(me,'DESIGN','Outstar','','Chapter 15');
set(fig, ...
'windowbuttondownfcn',nncallbk(me,'down'), ...
'BackingStore','off',...
'nextplot','add');
H = get(fig,'userdata');
fig_axis = H(1);
desc_text = H(2);
% SOUND POINTERS
wind = uicontrol('visible','off','userdata',nndsnd(3));
knock = uicontrol('visible','off','userdata',nndsnd(5));
scan = uicontrol('visible','off','userdata',nndsnd(1));
classify = uicontrol('visible','off','userdata',nndsnd(4));
blip = uicontrol('visible','off','userdata',nndsnd(6));
bloop = uicontrol('visible','off','userdata',nndsnd(7));
blp = uicontrol('visible','off','userdata',nndsnd(9));
tribble = uicontrol('visible','off','userdata',nndsnd(8));
% ICON
nndicon(15,458,363,'shadow')
% CONVEYER BELT
deg = pi/180;
angle = [0:5:360]*deg;
cx = cos(angle);
cy = sin(angle);
% ENTRANCE BOX
x = 60;
y = 20;
fill([0 0 x+10 x+10],y+[70 50 50 70],nndkblue,...
'edgecolor','none')
fill(x+[10 10 50 50],y+[80 40 40 80],nndkblue,...
'edgecolor','none')
plot([0 x+[10 10 50 50 10 10] 0],...
y+[50 50 40 40 80 80 70 70],...
'color',nnred)
left_arrow = fill(x+30+[-5 -5 -10 0 10 5 5],y+60+[15 5 5 -15 5 5 15],nndkblue,...
'edgecolor',nnred,...
'erasemode','none');
fruit_ind = text(x-25,y+60,'Fruit',...
'color',[0.8 0.8 0],...
'fontweight','bold',...
'horiz','center',...
'erasemode','none');
% LEFT CIRCLE
line_angle = 45*deg;
fill(x-10+cx*10,y+10+cy*10,nnred,...
'edgecolor',nndkblue,...
'linewidth',2)
line_1 = plot(x-10+cos([0 pi]+line_angle)*8,y+10+sin([0 pi]+line_angle)*8,...
'color',nndkblue,...
'erasemode','none',...
'linewidth',2);
% RIGHT CIRCLE
x = 320;
fill(x+10+cx*10,y+10+cy*10,nnred,...
'edgecolor',nndkblue,...
'linewidth',2)
line_2 = plot(x+10+cos([0 pi]+line_angle)*8,y+10+sin([0 pi]+line_angle)*8,...
'color',nndkblue,...
'erasemode','none',...
'linewidth',2);
% BELT
plot([50 330],[y y]+20,...
'color',nndkblue,...
'linewidth',2)
plot([50 330],[y y],...
'color',nndkblue,...
'linewidth',2)
% SENSOR BOX #1
x = 130;
fill(x+[0 40 20],y+[40 40 80],nndkblue,...
'edgecolor',nnred)
fill(x+[0 40 40 0],y+[14 14 8 8],nndkblue,...
'edgecolor',nnred)
cross = plot(x+[15 25 20 25 15],y+[50 60 55 50 60],...
'color',nndkblue,...
'linewidth',3,...
'erasemode','none');
% SENSOR BOX #2
x = 210;
fill(x+[0 40 20],y+[40 40 80],nndkblue,...
'edgecolor',nnred)
fill(x+[0 40 40 0],y+[14 14 8 8],nndkblue,...
'edgecolor',nnred)
% EXIT BOX
x = 320;
fill([310 310 380 380],y+[70 50 50 70],nndkblue,...
'edgecolor','none')
fill(x-[10 10 50 50],y+[80 40 40 80],nndkblue,...
'edgecolor','none')
plot([378 x-[10 10 50 50 10 10] 378],y+[70 70 80 80 40 40 50 50],...
'color',nnred)
right_arrow = fill(x-30+[-5 -5 -10 0 10 5 5],y+60-[15 5 5 -15 5 5 15],nndkblue,...
'edgecolor',nnred,...
'erasemode','none');
top_ind = text(x+25,y+60,'Out',...
'color',[0.8 0.8 0],...
'fontweight','bold',...
'horiz','center',...
'erasemode','none');
bottom_ind = [0];
% BUTTONS
go_button = uicontrol(...
'units','points',...
'position',[400 150 60 20],...
'string','Fruit',...
'callback',[me '(''go'')']);
uicontrol(...
'units','points',...
'position',[400 120 60 20],...
'string','Clear',...
'callback',[me '(''clear'')'])
uicontrol(...
'units','points',...
'position',[400 90 60 20],...
'string','Contents',...
'callback','nndtoc')
uicontrol(...
'units','points',...
'position',[400 60 60 20],...
'string','Close',...
'callback',[me '(''close'')'])
% LOWER SEPERATION BAR
fill([0 0 380 380],130+[0 4 4 0],nndkblue,...
'edgecolor','none')
% UPPER SEPERATION BAR
fill([0 0 380 380],160+[0 4 4 0],nndkblue,...
'edgecolor','none')
% RADIO BUTTONS
set(nndtext(20,147,'First Scanner:','left'),...
'fontsize',12)
rb1 = uicontrol(...
'units','points',...
'position',[140 139 100 20],...
'string','Working',...
'style','radio',...
'value',1,...
'callback',[me '(''working'')']);
rb2 = uicontrol(...
'units','points',...
'position',[250 139 100 20],...
'string','Not Working',...
'style','radio',...
'callback',[me '(''notworking'')']);
W1 = eye(3);
W2 = [0; 0; 0];
set(fig,'nextplot','add')
% NETWORK INPUT #1
x1 = 83;
y1 = 320;
dy1 = 55;
ddy1 = -25;
nndtext(x1-5,y1,'Shape','right');
p1_box1 = fill(x1+[0 20 20 0 0],y1-10+[0 0 20 20 0],nnltgray,...
'edgecolor',nnred,...
'linewidth',2,...
'erasemode','none');
p1_text1 = nndtext(x1+10,y1,'?');
nndtext(x1-5,y1+ddy1,'Texture','right');
p1_box2 = fill(x1+[0 20 20 0 0],y1-10+[0 0 20 20 0]+ddy1,nnltgray,...
'edgecolor',nnred,...
'linewidth',2,...
'erasemode','none');
p1_text2 = nndtext(x1+10,y1+ddy1,'?');
nndtext(x1-5,y1+2*ddy1,'Weight','right');
p1_box3 = fill(x1+[0 20 20 0 0],y1-10+[0 0 20 20 0]+2*ddy1,nnltgray,...
'edgecolor',nnred,...
'linewidth',2,...
'erasemode','none');
p1_text3 = nndtext(x1+10,y1+2*ddy1,'?');
% NETWORK INPUT #2
y3 = y1-2*dy1;
dy3 = 20;
nndtext(x1-5,y3,'Pineapple?','right');
p2_box = fill(x1+[0 20 20 0 0],y3-10+[0 0 20 20 0],nnltgray,...
'edgecolor',nnred,...
'linewidth',2,...
'erasemode','none');
p2_text = nndtext(x1+10,y3,'?');
% NEURONS
x2 = x1+155;
y2 = y1-dy1-12.5;
dy2 = 67.5;
sumdist = 50;
sz = 15;
plot(x2+[0 sumdist],y2+[0 0]+dy2,'linewidth',2,'color',nnred);
plot(x2+sumdist+sz+[10 20 0 20 10],y2+[10 0 0 0 -10]+dy2,'linewidth',2,'color',nnred);
nndtext(x2+sumdist+sz+45,y2+25+dy2,'Shape');
nndsicon('sum',x2,y2+dy2,sz)
nndsicon('satlins',x2+sumdist,y2+dy2,sz)
a_box1 = fill(x2+sumdist+sz+25+[0 40 40 0 0],y2-10+[0 0 20 20 0]+dy2,nnltgray,...
'edgecolor',nnred,...
'linewidth',2,...
'erasemode','none');
a_text1 = nndtext(x2+sumdist+sz+45,y2+dy2,'?');
plot(x2+[0 sumdist],y2+[0 0],'linewidth',2,'color',nnred);
plot(x2+sumdist+sz+[10 20 0 20 10],y2+[10 0 0 0 -10],'linewidth',2,'color',nnred);
nndtext(x2+sumdist+sz+45,y2+25,'Texture');
nndsicon('sum',x2,y2,sz)
nndsicon('satlins',x2+sumdist,y2,sz)
a_box2 = fill(x2+sumdist+sz+25+[0 40 40 0 0],y2-10+[0 0 20 20 0],nnltgray,...
'edgecolor',nnred,...
'linewidth',2,...
'erasemode','none');
a_text2 = nndtext(x2+sumdist+sz+45,y2,'?');
plot(x2+[0 sumdist],y2+[0 0]-dy2,'linewidth',2,'color',nnred);
plot(x2+sumdist+sz+[10 20 0 20 10],y2+[10 0 0 0 -10]-dy2,'linewidth',2,'color',nnred);
nndtext(x2+sumdist+sz+45,y2+25-dy2,'Weight');
nndsicon('sum',x2,y2-dy2,sz)
nndsicon('satlins',x2+sumdist,y2-dy2,sz)
a_box3 = fill(x2+sumdist+sz+25+[0 40 40 0 0],y2-10+[0 0 20 20 0]-dy2,nnltgray,...
'edgecolor',nnred,...
'linewidth',2,...
'erasemode','none');
a_text3 = nndtext(x2+sumdist+sz+45,y2-dy2,'?');
% WEIGHTS #1
straight = 95;
plot([x1+20 x1+straight-50],[y1 y1],'linewidth',2,'color',nnred);
plot([x1+straight-10 x1+straight x2-sz],[y1 y1 y2+dy2],'linewidth',2,'color',nnred);
plot(x1+straight-50+[0 40 40 0 0],y1-10+[0 0 20 20 0],'color',nnred,'linewidth',2);
nndtext(x1+straight-30,y1,'1');
plot([x1+20 x1+straight-50],[y1 y1]+ddy1,'linewidth',2,'color',nnred);
plot([x1+straight-10 x1+straight x2-sz],[y1+ddy1 y1+ddy1 y2],'linewidth',2,'color',nnred);
plot(x1+straight-50+[0 40 40 0 0],y1-10+[0 0 20 20 0]+ddy1,'color',nnred,'linewidth',2);
nndtext(x1+straight-30,y1+ddy1,'1');
plot([x1+20 x1+straight-50],[y1 y1]+2*ddy1,'linewidth',2,'color',nnred);
plot([x1+straight-10 x1+straight x2-sz],[y1+2*ddy1 y1+2*ddy1 y2-dy2],'linewidth',2,'color',nnred);
plot(x1+straight-50+[0 40 40 0 0],y1-10+[0 0 20 20 0]+2*ddy1,'color',nnred,'linewidth',2);
nndtext(x1+straight-30,y1+2*ddy1,'1');
% WEIGHTS #2
straight_dist = 100;
plot([x1+20 x1+straight-50],[y3 y3-ddy1],'linewidth',2,'color',nnred);
plot([x1+straight-10 x1+straight x2-sz],[y3-ddy1 y3-ddy1 y2+dy2],'linewidth',2,'color',nnred);
W2_box1 = fill(x1+straight-50+[0 40 40 0 0],y3-10+[0 0 20 20 0]-ddy1,nnltgray,...
'edgecolor',nnred,...
'linewidth',2,...
'erasemode','none');
W2_text1 = nndtext(x1+straight-30,y3-ddy1,sprintf('%5.2f',W2(1)));
plot([x1+20 x1+straight-50],[y3 y3],'linewidth',2,'color',nnred);
plot([x1+straight-10 x1+straight x2-sz],[y3 y3 y2],'linewidth',2,'color',nnred);
W2_box2 = fill(x1+straight-50+[0 40 40 0 0],y3-10+[0 0 20 20 0],nnltgray,...
'edgecolor',nnred,...
'linewidth',2,...
'erasemode','none');
W2_text2 = nndtext(x1+straight-30,y3,sprintf('%5.2f',W2(2)));
plot([x1+20 x1+straight-50],[y3 y3+ddy1],'linewidth',2,'color',nnred);
plot([x1+straight-10 x1+straight x2-sz],[y3+ddy1 y3+ddy1 y2-dy2],'linewidth',2,'color',nnred);
W2_box3 = fill(x1+straight-50+[0 40 40 0 0],y3-10+[0 0 20 20 0]+ddy1,nnltgray,...
'edgecolor',nnred,...
'linewidth',2,...
'erasemode','none');
W2_text3 = nndtext(x1+straight-30,y3+ddy1,sprintf('%5.2f',W2(3)));
% INPUT HEADING
temp = nndtext(x1+10,y1+25,'Inputs');
% WEIGHT HEADING
nndtext(x1+straight_dist-35,y1+25,'Weights');
% SCANNER NAMES
set(nndtext(150,122,'Shape, Texture,'),...
'fontsize',10)
set(nndtext(150,108,'& Weight'),...
'fontsize',10)
set(nndtext(230,122,''),...
'fontsize',10)
set(nndtext(230,108,'Pineapple?'),...
'fontsize',10)
% SAVE WINDOW DATA AND LOCK
angle_ptr = uicontrol('visible','off','userdata',line_angle);
fruit_ptr = uicontrol('visible','off','userdata',[]);
p1_ptr = uicontrol('visible','off','userdata',[]);
p2_ptr = uicontrol('visible','off','userdata',[]);
a_ptr = uicontrol('visible','off','userdata',[]);
W2_ptr = uicontrol('visible','off','userdata',W2);
W2_ptr = uicontrol('visible','off','userdata',W2);
mode_ptr = uicontrol('visible','off','userdata',1);
H = [fig_axis, ...
desc_text, ...
line_1 line_2, ...
fruit_ind top_ind bottom_ind, ...
wind knock scan classify blip bloop blp tribble, ...
angle_ptr fruit_ptr 0 0 0, ...
left_arrow right_arrow,rb1 rb2 cross, ...
p1_ptr p2_ptr a_ptr W2_ptr,...
p1_box1 p1_text1 p1_box2 p1_text2 p1_box3 p1_text3, ...
p2_box p2_text, ...
a_box1 a_text1 a_box2 a_text2 a_box3 a_text3,...
go_button mode_ptr, ...
W2_box1 W2_text1 W2_box2 W2_text2 W2_box3 W2_text3];
set(fig,'userdata',H,'nextplot','new')
% INSTRUCTION TEXT
feval(me,'instr');
% LOCK WINDOW
set(fig,...
'nextplot','new',...
'color',nnltgray);
nnchkfs;
%==================================================================
% Display the instructions.
%
% ME('instr')
%==================================================================
elseif strcmp(cmd,'instr') & (fig)
nnsettxt(desc_text,...
'Click [Fruit] to send',...
'a fruit down the belt.',...
'Click [Update] to apply',...
'the outstar rule.',...
'',...
'Once the network has',...
'seen several',...
'pineapples with both',...
'scanners, it will',...
'recall their',...
'measurements with',...
'the first scanner off.')
%==================================================================
% Respond to fruit.
%
% ME('fruit')
%==================================================================
elseif strcmp(cmd,'go') & (fig) & (nargin == 1) & (mode == 1);
% GET DATA
wind = get(sounds(1),'userdata');
knock = get(sounds(2),'userdata');
scan = get(sounds(3),'userdata');
classify = get(sounds(4),'userdata');
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -