Step 4:  

clear;
clc;
close all;

 X=[0 0       %input matrix
        0 1
        1 0
        1 1];
 
  D=[0        %correct output matrix
        1
        1
        0];

W1=rand(4,2); %assign random weights to connections between input and hidden layers
W2=rand(1,4); %assign random weights to connections between hidden and output layers

for epoch=1:10000  %start training the network

[W1 W2] = BackpropXOR(W1,W2,X,D);  %each epoch produces W1 and W2 matrices that are a little closer to the final values of the weights

end; %for epoch

%at the end of the 10,000 epochs, your network is trained