clear;clf;
N=300;
ustar = [zeros(round(N/2),1);ones(N+1-round(N/2),1)];
v = ustar + 0.1*randn(N+1,1);
D=eye(N+1);
for i=2:N+1
    D(i,i)=2;
    D(i-1,i)=-1;
    D(i,i-1)=-1;
end
D(N+1,N+1)=1;


mue=0.001;
h=1/N;

u=(mue/(h^2)*D+eye(N+1))\v;


x = linspace(0,1,N+1);
plot(x,ustar,'b')
hold on
plot(x,v,'g')
plot(x,u,'r')
legend('u*','v','u');