does anyone know why this neural network is not giving the right target values?

%a=imread('A.bmp');
%a=imresize(a,[6,5]);
%a=imresize(a,[1,30]);
inp=[0 0 1 0 0 0 0 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 1 1 1 0 0 0 1];
out=[1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0];
net= newff(inp,out,10)
tol = 0.001; % Error tolerance
%net.trainParam.show = 50;
net.trainParam.lr = 0.007;
net.trainParam.epochs = 500;
net.trainParam.alpha = 0.5;
%net.trainParam.goal = 1e-5;
[net,tr]=train(net,inp,out);
a=sim(net,inp)

ANSWER

plot(input,target,'o')
close all, clear all, clc

N =30
input = [0 0 1 0 0 0 0 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 1 1 1 0 0 0 1];
target = [ 1, zeros( 1,N-1)];
y00   = (1/N)*ones(1,N); % 0.0333*ones(1,30)
e00 = target-y00; ; % [ 0.9667, -0.0333*ones(1,29)]
MSE00 = mse(target-y00) % 0.0322
W0    =  target/[ ones(1,N) ; input ] % W0 = [ 0.0588 -0.0588 ]
y0 = W0 * [ ones(1,N) ; input ]; % y0 = 0.0588*(1-input)
e0 = target-y0; ; % [ 0.9412, -y0(2:end)]
MSE0 = mse(target-y0) % 0.0314 Not much better than constant model
R20 = 1 - MSE0/MSE00 % 0.0264 VERY BAD FIT

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.