Step 3:
New steps are shown in green
function [W1, W2] = BackpropXOR(W1,W2,X,D);
alpha=0.9; %learning rate
[R C]=size(X); %Get the number of rows and columns of the input matrix X
%R = number of training trials. C = number of input nodesfor k=1:R %each row is a training trials.
x=X(k,:)'; %Extract each training trial (row of X). Note the transpose symbol.
d=D(k); %Extract the correct answer for that trial.
v1=W1*x; %calculate the value of the nodes of the hidden layer (1st layer)
y1=1./(1+exp(-v1)); %Sigmoid activation function
v=W2*y1; %calculate the value of the output node
y=1./(1+exp(-v)); %Sigmoid activation functionend; % for k=1:R