Step 2:  

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 nodes

%Lets also start a loop which can take each row of the training data and calculates updated weights.

for k=1:R  %each row is a training trials.   

What goes in here?  See next step.

end; % for k=1:R