i want to implement back propagation algorithm in matlab.

the algorithm is follows

1.Apply input to the input units

2.Calculate the net-input values to the hidden layer units.

3.Calculate the outputs from the hidden layer.

4.Calculate the net-input values to the output layer units.

5.Calculate output from the output units.

6.Calculate the error term for the output units using.

New δopk=1+exp [(Ypk-Opk)2].fok(netopk), if (Y-O)>=zero

7.Calculate the error term for the hidden units,through applying Newδpk, also

New δopk=-{1+exp [(Ypk-Opk)2].fok(netopk)}, if (Y-O) <=zero

8.Update the weights on the output layer .

Wokj(t+1) =Wokj(t)+(η.Newδopk.ipj).

9.Update the weights on the hidden layer.

Whji(t+1) =Whji(t) + (η.Newδhpj.Xi).

Repeat steps from step 1 to step 9 until the error( Ypk-Opk)is acceptably small For each training vectors

on implementing this the error increases instead decreasing,i want the respective change in step 6 and 7 to get decrease the error.