Professional Documents
Culture Documents
Experiment: Implementation of Learning Method by Hebb'S Rule Program
Experiment: Implementation of Learning Method by Hebb'S Rule Program
PROGRAM:
clc;
clear all;
fprintf('\nInitial weights are\n');
wr=input('\nrow of w\n');
wc=input('\ncolumn of w\n');
for i=1:wr
for j=1:wc
w(i,j)=input('\nvalues\n');
end
end
display(w);
xr=input('\nrow of x\n');
xc=input('\ncolumn of x\n');
for i=1:xr
for j=1:xc
x(i,j)=input('\nvalues\n');
end
end
display(x);
c=input('\nvalue of learning constant\n');
n=input('\nnumber of input datapoints\n');
for i=1:n
xn=x(:,i);
display(xn);
net=w.'*xn;
func=sign(net);
w1=c*func*xn;
w=w+w1;
end
fprintf('\nThe final updated weights are\n')
display(w);
OUTPUT
row of w
column of w
values
values
-1
values
values
0.5
w = 1.0000
-1.0000
0.5000
row of x
column of x
Values 1
Values 1
Values 0
Values -2
Values -0.5
Values 1
Values 1.5
Values -2
Values -1
Values 0
values -1.5
values 1.5
x=
1.0000 1.0000 0
0 -1.5000 1.5000
xn = 1.0000
-2.0000
1.5000
xn =1.0000
-0.5000
-2.0000
-1.5000
xn = 0
1.0000
-1.0000
1.5000
w = 1.0000
-3.5000
4.5000
0.5000