Question: With the output % Generate XOR function using McCulloch - Pitts neuron by writing an M - file. % XOR function using McCulloch - Pitts

With the output
% 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=');
disp('Enter Threshold Value');
theta=input('theta=');
x1=[0011];
x2=[0101];
z=[0110];
con=1;
while con
zin1=x1*w1+x2*w3;
zin2=x1*w2+x2*w4;
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;
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=');
end
end
disp('McCulloch-Pitts Net for XOR 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=1
% weight v2=1
% Enter Threshold Value
% theta=1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!