SlideShare a Scribd company logo
1 of 6
Download to read offline
% % Generate XOR function using McCulloch-Pitts neuron by writing an M-file.
%XOR function using McCulloch-Pitts neuron
clear all
close all;
clc;
%Getting weights and threshold value
disp('Enter weights');
w1=input('Weight w1=');
w2=input('weight w2=');
w3=input('Weight w3=');
w4=input('weight w4=');
v1=input('weight v1=');
v2=input('weight v2=');
b1=input('bias 1=');
b2=input('bias 2=');
b3=input('bias 3=');
disp('Enter Threshold Value');
theta=input('theta=');
x1=[0 0 1 1];
x2=[0 1 0 1];
z=[1 0 0 1];
con=1;
while con
zin1=x1*w1+x2*w3+1*b1;
zin2=x1*w2+x2*w4+1*b2;
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*v1+y2*v2+1*b3;
for i=1:4
if yin(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=');
w3=input('Weight w3=');
w4=input('weight w4=');
v1=input('weight v1=');
v2=input('weight v2=');
theta=input('theta=');
b1=input('bias 1=');
b2=input('bias 2=');
b3=input('bias 3=');
end
end
disp('McCulloch-Pitts Net for XNOR function');
disp('Weights of Neuron Z1');
disp(w1);
disp(w3);
disp('weights of Neuron Z2');
disp(w2);
disp(w4);
disp('weights of Neuron Y');
disp(v1);
disp(v2);
disp('Threshold value');
disp(theta);
% Enter weights
% Weight w1=1
% weight w2=-1
% Weight w3=1
% weight w4=-1
% weight v1=2
% weight v2=2
% Enter Threshold Value
% theta=1
% b1=-1
% b2=1
% b3=-1
% % Generate XOR function using McCulloch-Pitts neuron by writing an M-file.
%XOR function using McCulloch-Pitts neuron
clear all
close all;
clc;
%Getting weights and threshold value
disp('Enter weights');
w1=input('Weight w1=');
w2=input('weight w2=');
w3=input('Weight w3=');
w4=input('weight w4=');
v1=input('weight v1=');
v2=input('weight v2=');
b1=input('bias 1=');
b2=input('bias 2=');
b3=input('bias 3=');
disp('Enter Threshold Value');
theta=input('theta=');
x1=[0 0 1 1];
x2=[0 1 0 1];
z=[1 0 0 1];
con=1;
while con
zin1=x1*w1+x2*w3+1*b1;
zin2=x1*w2+x2*w4+1*b2;
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*v1+y2*v2+1*b3;
for i=1:4
if yin(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=');
w3=input('Weight w3=');
w4=input('weight w4=');
v1=input('weight v1=');
v2=input('weight v2=');
theta=input('theta=');
b1=input('bias 1=');
b2=input('bias 2=');
b3=input('bias 3=');
end
end
disp('McCulloch-Pitts Net for XNOR function');
disp('Weights of Neuron Z1');
disp(w1);
disp(w3);
disp('weights of Neuron Z2');
disp(w2);
disp(w4);
disp('weights of Neuron Y');
disp(v1);
disp(v2);
disp('Threshold value');
disp(theta);
% Enter weights
% Weight w1=1
% weight w2=-1
% Weight w3=1
% weight w4=-1
% weight v1=2
% weight v2=2
% Enter Threshold Value
% theta=1
% b1=-1
% b2=1
% b3=-1
Laboratory Experiment No. Title Introduction Objectives Materials Procedure Results
Discussion Conclusion References

More Related Content

More from mdualudin007

(1 Point) Please match the following variable properties with their d.pdf
 (1 Point) Please match the following variable properties with their d.pdf (1 Point) Please match the following variable properties with their d.pdf
(1 Point) Please match the following variable properties with their d.pdfmdualudin007
 
(1 point) If samples of size 37 are taken from a population with mean.pdf
 (1 point) If samples of size 37 are taken from a population with mean.pdf (1 point) If samples of size 37 are taken from a population with mean.pdf
(1 point) If samples of size 37 are taken from a population with mean.pdfmdualudin007
 
Bag breaks open; included as delay in the allowance factor Conveyo.pdf
  Bag breaks open; included as delay in the allowance factor  Conveyo.pdf  Bag breaks open; included as delay in the allowance factor  Conveyo.pdf
Bag breaks open; included as delay in the allowance factor Conveyo.pdfmdualudin007
 
Prove the following E(MSR)=2+12(Xix)2.pdf
  Prove the following E(MSR)=2+12(Xix)2.pdf  Prove the following E(MSR)=2+12(Xix)2.pdf
Prove the following E(MSR)=2+12(Xix)2.pdfmdualudin007
 
Computer Architecture HOW do I design a computer = Instruction .pdf
  Computer Architecture HOW do I design a computer  = Instruction .pdf  Computer Architecture HOW do I design a computer  = Instruction .pdf
Computer Architecture HOW do I design a computer = Instruction .pdfmdualudin007
 
( Ch2 ISA)3. Assume that the top of the stack in a progra.pdf
 ( Ch2 ISA)3. Assume that the top of the stack in a progra.pdf ( Ch2 ISA)3. Assume that the top of the stack in a progra.pdf
( Ch2 ISA)3. Assume that the top of the stack in a progra.pdfmdualudin007
 
The goal of this assignment is to get familiar with pipelining in C.pdf
  The goal of this assignment is to get familiar with pipelining in C.pdf  The goal of this assignment is to get familiar with pipelining in C.pdf
The goal of this assignment is to get familiar with pipelining in C.pdfmdualudin007
 
( 20 points) Benzene is a common groundwater contaminant. Based on a .pdf
 ( 20 points) Benzene is a common groundwater contaminant. Based on a .pdf ( 20 points) Benzene is a common groundwater contaminant. Based on a .pdf
( 20 points) Benzene is a common groundwater contaminant. Based on a .pdfmdualudin007
 
(2) Solve the following recurrence relation by using Recursion Trees .pdf
 (2) Solve the following recurrence relation by using Recursion Trees .pdf (2) Solve the following recurrence relation by using Recursion Trees .pdf
(2) Solve the following recurrence relation by using Recursion Trees .pdfmdualudin007
 
(20 pts) Let X and Y be two statistically independent random variable.pdf
 (20 pts) Let X and Y be two statistically independent random variable.pdf (20 pts) Let X and Y be two statistically independent random variable.pdf
(20 pts) Let X and Y be two statistically independent random variable.pdfmdualudin007
 
(2 pts.) Consider the following ordered list of data, x and a key.pdf
 (2 pts.) Consider the following ordered list of data,  x  and a key.pdf (2 pts.) Consider the following ordered list of data,  x  and a key.pdf
(2 pts.) Consider the following ordered list of data, x and a key.pdfmdualudin007
 
(2 points) (Problem 4.96) Suppose that a random variable Y has a prob.pdf
 (2 points) (Problem 4.96) Suppose that a random variable Y has a prob.pdf (2 points) (Problem 4.96) Suppose that a random variable Y has a prob.pdf
(2 points) (Problem 4.96) Suppose that a random variable Y has a prob.pdfmdualudin007
 
(1pts) Refer to figure above. At Q1, there is a tendency for Real GDP.pdf
 (1pts) Refer to figure above. At Q1, there is a tendency for Real GDP.pdf (1pts) Refer to figure above. At Q1, there is a tendency for Real GDP.pdf
(1pts) Refer to figure above. At Q1, there is a tendency for Real GDP.pdfmdualudin007
 
(15 pts) The joint density function of random variables X and Y is gi.pdf
 (15 pts) The joint density function of random variables X and Y is gi.pdf (15 pts) The joint density function of random variables X and Y is gi.pdf
(15 pts) The joint density function of random variables X and Y is gi.pdfmdualudin007
 
(12 points) X and Y are identically distributed random variables with.pdf
 (12 points) X and Y are identically distributed random variables with.pdf (12 points) X and Y are identically distributed random variables with.pdf
(12 points) X and Y are identically distributed random variables with.pdfmdualudin007
 
(10 points) A Bernoull difterential equation is one of the form dxdy+.pdf
 (10 points) A Bernoull difterential equation is one of the form dxdy+.pdf (10 points) A Bernoull difterential equation is one of the form dxdy+.pdf
(10 points) A Bernoull difterential equation is one of the form dxdy+.pdfmdualudin007
 
�rg�tsel davranzlenim Y�netimi, Giriim Sermayesi Tarz Giriim kap.pdf
�rg�tsel davranzlenim Y�netimi, Giriim Sermayesi Tarz Giriim kap.pdf�rg�tsel davranzlenim Y�netimi, Giriim Sermayesi Tarz Giriim kap.pdf
�rg�tsel davranzlenim Y�netimi, Giriim Sermayesi Tarz Giriim kap.pdfmdualudin007
 
�Qu� tipo de profesional de recursos humanos utiliza varios m�todos,.pdf
�Qu� tipo de profesional de recursos humanos utiliza varios m�todos,.pdf�Qu� tipo de profesional de recursos humanos utiliza varios m�todos,.pdf
�Qu� tipo de profesional de recursos humanos utiliza varios m�todos,.pdfmdualudin007
 
�� aylk yatrm i�in fazladan 1.000.000 ABD dolar olan IBMin sayman o.pdf
�� aylk yatrm i�in fazladan 1.000.000 ABD dolar olan IBMin sayman o.pdf�� aylk yatrm i�in fazladan 1.000.000 ABD dolar olan IBMin sayman o.pdf
�� aylk yatrm i�in fazladan 1.000.000 ABD dolar olan IBMin sayman o.pdfmdualudin007
 

More from mdualudin007 (19)

(1 Point) Please match the following variable properties with their d.pdf
 (1 Point) Please match the following variable properties with their d.pdf (1 Point) Please match the following variable properties with their d.pdf
(1 Point) Please match the following variable properties with their d.pdf
 
(1 point) If samples of size 37 are taken from a population with mean.pdf
 (1 point) If samples of size 37 are taken from a population with mean.pdf (1 point) If samples of size 37 are taken from a population with mean.pdf
(1 point) If samples of size 37 are taken from a population with mean.pdf
 
Bag breaks open; included as delay in the allowance factor Conveyo.pdf
  Bag breaks open; included as delay in the allowance factor  Conveyo.pdf  Bag breaks open; included as delay in the allowance factor  Conveyo.pdf
Bag breaks open; included as delay in the allowance factor Conveyo.pdf
 
Prove the following E(MSR)=2+12(Xix)2.pdf
  Prove the following E(MSR)=2+12(Xix)2.pdf  Prove the following E(MSR)=2+12(Xix)2.pdf
Prove the following E(MSR)=2+12(Xix)2.pdf
 
Computer Architecture HOW do I design a computer = Instruction .pdf
  Computer Architecture HOW do I design a computer  = Instruction .pdf  Computer Architecture HOW do I design a computer  = Instruction .pdf
Computer Architecture HOW do I design a computer = Instruction .pdf
 
( Ch2 ISA)3. Assume that the top of the stack in a progra.pdf
 ( Ch2 ISA)3. Assume that the top of the stack in a progra.pdf ( Ch2 ISA)3. Assume that the top of the stack in a progra.pdf
( Ch2 ISA)3. Assume that the top of the stack in a progra.pdf
 
The goal of this assignment is to get familiar with pipelining in C.pdf
  The goal of this assignment is to get familiar with pipelining in C.pdf  The goal of this assignment is to get familiar with pipelining in C.pdf
The goal of this assignment is to get familiar with pipelining in C.pdf
 
( 20 points) Benzene is a common groundwater contaminant. Based on a .pdf
 ( 20 points) Benzene is a common groundwater contaminant. Based on a .pdf ( 20 points) Benzene is a common groundwater contaminant. Based on a .pdf
( 20 points) Benzene is a common groundwater contaminant. Based on a .pdf
 
(2) Solve the following recurrence relation by using Recursion Trees .pdf
 (2) Solve the following recurrence relation by using Recursion Trees .pdf (2) Solve the following recurrence relation by using Recursion Trees .pdf
(2) Solve the following recurrence relation by using Recursion Trees .pdf
 
(20 pts) Let X and Y be two statistically independent random variable.pdf
 (20 pts) Let X and Y be two statistically independent random variable.pdf (20 pts) Let X and Y be two statistically independent random variable.pdf
(20 pts) Let X and Y be two statistically independent random variable.pdf
 
(2 pts.) Consider the following ordered list of data, x and a key.pdf
 (2 pts.) Consider the following ordered list of data,  x  and a key.pdf (2 pts.) Consider the following ordered list of data,  x  and a key.pdf
(2 pts.) Consider the following ordered list of data, x and a key.pdf
 
(2 points) (Problem 4.96) Suppose that a random variable Y has a prob.pdf
 (2 points) (Problem 4.96) Suppose that a random variable Y has a prob.pdf (2 points) (Problem 4.96) Suppose that a random variable Y has a prob.pdf
(2 points) (Problem 4.96) Suppose that a random variable Y has a prob.pdf
 
(1pts) Refer to figure above. At Q1, there is a tendency for Real GDP.pdf
 (1pts) Refer to figure above. At Q1, there is a tendency for Real GDP.pdf (1pts) Refer to figure above. At Q1, there is a tendency for Real GDP.pdf
(1pts) Refer to figure above. At Q1, there is a tendency for Real GDP.pdf
 
(15 pts) The joint density function of random variables X and Y is gi.pdf
 (15 pts) The joint density function of random variables X and Y is gi.pdf (15 pts) The joint density function of random variables X and Y is gi.pdf
(15 pts) The joint density function of random variables X and Y is gi.pdf
 
(12 points) X and Y are identically distributed random variables with.pdf
 (12 points) X and Y are identically distributed random variables with.pdf (12 points) X and Y are identically distributed random variables with.pdf
(12 points) X and Y are identically distributed random variables with.pdf
 
(10 points) A Bernoull difterential equation is one of the form dxdy+.pdf
 (10 points) A Bernoull difterential equation is one of the form dxdy+.pdf (10 points) A Bernoull difterential equation is one of the form dxdy+.pdf
(10 points) A Bernoull difterential equation is one of the form dxdy+.pdf
 
�rg�tsel davranzlenim Y�netimi, Giriim Sermayesi Tarz Giriim kap.pdf
�rg�tsel davranzlenim Y�netimi, Giriim Sermayesi Tarz Giriim kap.pdf�rg�tsel davranzlenim Y�netimi, Giriim Sermayesi Tarz Giriim kap.pdf
�rg�tsel davranzlenim Y�netimi, Giriim Sermayesi Tarz Giriim kap.pdf
 
�Qu� tipo de profesional de recursos humanos utiliza varios m�todos,.pdf
�Qu� tipo de profesional de recursos humanos utiliza varios m�todos,.pdf�Qu� tipo de profesional de recursos humanos utiliza varios m�todos,.pdf
�Qu� tipo de profesional de recursos humanos utiliza varios m�todos,.pdf
 
�� aylk yatrm i�in fazladan 1.000.000 ABD dolar olan IBMin sayman o.pdf
�� aylk yatrm i�in fazladan 1.000.000 ABD dolar olan IBMin sayman o.pdf�� aylk yatrm i�in fazladan 1.000.000 ABD dolar olan IBMin sayman o.pdf
�� aylk yatrm i�in fazladan 1.000.000 ABD dolar olan IBMin sayman o.pdf
 

Recently uploaded

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 

Recently uploaded (20)

INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 

Generate XOR function using McCulloch-Pitts neuron by writing .pdf

  • 1. % % Generate XOR function using McCulloch-Pitts neuron by writing an M-file. %XOR function using McCulloch-Pitts neuron clear all close all; clc; %Getting weights and threshold value disp('Enter weights'); w1=input('Weight w1='); w2=input('weight w2='); w3=input('Weight w3='); w4=input('weight w4='); v1=input('weight v1='); v2=input('weight v2='); b1=input('bias 1='); b2=input('bias 2='); b3=input('bias 3='); disp('Enter Threshold Value'); theta=input('theta='); x1=[0 0 1 1]; x2=[0 1 0 1]; z=[1 0 0 1]; con=1; while con zin1=x1*w1+x2*w3+1*b1; zin2=x1*w2+x2*w4+1*b2; for i=1:4 if zin1(i)>=theta y1(i)=1; else y1(i)=0; end if zin2(i)>=theta y2(i)=1; else
  • 2. y2(i)=0; end end yin=y1*v1+y2*v2+1*b3; for i=1:4 if yin(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='); w3=input('Weight w3='); w4=input('weight w4='); v1=input('weight v1='); v2=input('weight v2='); theta=input('theta='); b1=input('bias 1='); b2=input('bias 2='); b3=input('bias 3='); end end disp('McCulloch-Pitts Net for XNOR function'); disp('Weights of Neuron Z1'); disp(w1); disp(w3); disp('weights of Neuron Z2'); disp(w2); disp(w4);
  • 3. disp('weights of Neuron Y'); disp(v1); disp(v2); disp('Threshold value'); disp(theta); % Enter weights % Weight w1=1 % weight w2=-1 % Weight w3=1 % weight w4=-1 % weight v1=2 % weight v2=2 % Enter Threshold Value % theta=1 % b1=-1 % b2=1 % b3=-1 % % Generate XOR function using McCulloch-Pitts neuron by writing an M-file. %XOR function using McCulloch-Pitts neuron clear all close all; clc; %Getting weights and threshold value disp('Enter weights'); w1=input('Weight w1='); w2=input('weight w2='); w3=input('Weight w3='); w4=input('weight w4=');
  • 4. v1=input('weight v1='); v2=input('weight v2='); b1=input('bias 1='); b2=input('bias 2='); b3=input('bias 3='); disp('Enter Threshold Value'); theta=input('theta='); x1=[0 0 1 1]; x2=[0 1 0 1]; z=[1 0 0 1]; con=1; while con zin1=x1*w1+x2*w3+1*b1; zin2=x1*w2+x2*w4+1*b2; 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*v1+y2*v2+1*b3; for i=1:4 if yin(i)>=theta; y(i)=1; else y(i)=0; end end disp('Output of Net'); disp(y);
  • 5. 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='); w3=input('Weight w3='); w4=input('weight w4='); v1=input('weight v1='); v2=input('weight v2='); theta=input('theta='); b1=input('bias 1='); b2=input('bias 2='); b3=input('bias 3='); end end disp('McCulloch-Pitts Net for XNOR function'); disp('Weights of Neuron Z1'); disp(w1); disp(w3); disp('weights of Neuron Z2'); disp(w2); disp(w4); disp('weights of Neuron Y'); disp(v1); disp(v2); disp('Threshold value'); disp(theta); % Enter weights % Weight w1=1 % weight w2=-1 % Weight w3=1
  • 6. % weight w4=-1 % weight v1=2 % weight v2=2 % Enter Threshold Value % theta=1 % b1=-1 % b2=1 % b3=-1 Laboratory Experiment No. Title Introduction Objectives Materials Procedure Results Discussion Conclusion References