Step 3:  

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

What should go in here? See next step.

end; %for epoch