Space In HIndi

 


Pages

Popular

IMPLEMENTATION OF LOGIC GATES USING Mc Cullah Pits Neuron Exp-1

 EXPERIMENT NO-01:

IMPLEMENTATION OF LOGIC GATES USING McCullah Pits Neuron

clear;
clc;
disp('IMPLEMENTATION OF LOGIC GATES USING Mc Cullah Pits Neuron');
disp('Which Gate You want to Implement');
choice=input('1:OR 2: AND 3: NAND 4:NOR 5:ANDNOT=>')
y=[0 0 0 0];
x=[0 0 1 1;0 1 0 1];
switch choice
case 1
z=[0 1 1 1];
case 2
z=[0 0 0 1];
case 3
z=[1 1 1 0];
case 4
z=[1 0 0 0];
case 5
z=[0 0 1 0];
otherwise
error('Wrong Choice');
end
cont=1;
while cont
disp('Enter the Weight');
w1=input('w1=');
w2=input('w2=');
theta=input('Enter threshold=');
zin=x(1,:)*w1+x(2,:)*w2;
for i=1:4
if zin(i)>=theta;
y(i)=1;
else
y(i)=0;
end
end
disp('The Output of NET is=');
disp(y);
if y==z
cont=0;
disp(' The values of weights and Threshold are correct');
disp('The MP Neuron is trained for the given function');
else
disp('NET is not Learning');
disp('Another set of weight and Threshold');
end
end
                       EXPERIMENT NO-01:

IMPLEMENTATION OF EX-OR GATES USING Mc Cullah Pits Neuron
clear;
clc;
disp('IMPLEMENTATION OF EX-OR GATES USING Mc Cullah Pits Neuron');
x1=[0 0 1 1];
x2=[0 1 0 1];
z=[0 1 1 0];
disp('Enter the Weight');
w11=input('w11=');
w12=input('w12=');
w21=input('w21=');
w22=input('w22=');
w1=input('w1=');
w2=input('w2=');
theta=input('Enter threshold=>');
cont=1;
while cont
zin1=x1*w11+x2*w12;
zin2=x1*w21+x2*w22;
for i=1:4
if zin1(i)>=theta;
y1(i)=1;
else
y1(i)=0;
end
if zin2(i)>=theta;
y2(i)=1;
else
y2(i)=0;
end
end
yin=y1*w1+y2*w2;
for i=1:4
if yin(i)>=theta;
y(i)=1;
else
y(i)=0;
end
end
disp('The Output of NET is=');
disp(y);
if y==z
cont=0;
else
disp('NET is not Learning Enter Another set of weight and Threshold');
disp('Enter the Weight');
w11=input('w11=');
w12=input('w12=');
w21=input('w21=');
w22=input('w22=');
w1=input('w1=');
w2=input('w2=');
theta=input('Enter threshold=>');
end
end
disp('Weights of Neuron Z1');
disp('w11');
disp('w21');
disp('Weights of Neuron Z2');

disp('w12');
disp('w22');
disp(' Weights of Neuron Y');
disp ('w1');
disp ('w2');
disp ('Display Threshold Value');
disp ('theta');

No comments: