X1 X2 Y
0 0 0
0 1 0
1 0 1
1 1 0
example37.m
%ANDNOT function using Mcculloch-Pitts neuron
clear;
clc;
%Getting weights and threshold value
disp('Enter weights');
w1 = input('Weight w1 = ');
w2 = input('Weight w2 = ');
disp('Enter Threshold Value');
theta = input('thete = ');
y = [0 0 0 0];
x1 = [0 0 1 1];
x2 = [0 1 0 1];
z = [0 0 1 0];
con = 1;
while con
zin = x1 * w1 + x2 * w2;
for i = 1:4
if zin(i) >= theta
y(i) = 1;
else
y(i) = 0;
end
end
disp('Output of Net');
disp(y);
if y == z
con = 0;
else
disp('Net is not learning enter another set of weights and threshold value');
w1 = input('Weight w1 = ');
w2 = input('Weight w2 = ');
theta = input('thete = ');
end
end
disp('Mcculloch-Pitts Net for ANDNOT function');
disp('Weights of Neuron');
disp(w1);
disp(w2);
disp('Threshold value');
disp(theta);
0 comments:
Catat Ulasan
Terima kasih kerana memberi ulasan...