Step 1:  


Start by defining our input data X, and the correct answers D (these are the values shown in the truth table).

clear;
clc;
close all;

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

Note that to use Matlab neural net functions, each column is supposed to be one training trial, so we'll have to flip X and D on their sides before training the network.

X=X';
D=D';