sc
sc
clear; clc;
Weight w1=1
w1=input('Weight w1='); w2=input('Weight
Weight w2=1
w2='); disp('Enter threshold value');
Enter threshold value theta=2
theta=input('theta='); y=[0 0 0 0]; x1=[1 1 0
Output of net=1 0 0 0
0]; x2=[1 0 1 0]; z=[1 0 0 0];
McCulloch Pitts Net for AND function
con=1; while con zin Weights of neuron
= x1*w1+x2*w2; 1
for i=1:4 if 1
2
else y(i)=0; end end
disp('Output of net=');
else disp('Net is not learning Enter another set of weights and threshold
theta=input('theta=');
end
Code:
clear; clc;
w1=input('Weight w1=');
w2=input('Weight w2=');
theta=input('theta='); y=[0 0 0
z=[1 1 1 0];
x1*w1+x2*w2;
for i=1:4 if
zin(i)>=theta
y(i)=1; else
y(i)=0;
con=0;
else disp('Net is not learning Enter another set of weights and threshold value');
value='); disp(theta);
Exp-3 Implement perceptron network for emulating the behavior of AND gate
clc;
Output: