clc
clear
clf

%----- BSP 3 Einfuehrung in die Numerik Blatt 1 ------

N=70;
h=1/N;
m=1;

I=eye(N+1);
I(1,1)=0; I(N+1,N+1)=0;
w=(-1).*ones(1,N);
D=eye(N+1)+I+diag(w,-1)+diag(w,1);

ustar=[zeros(round(N/2),1); ones(N+1-round(N/2),1)];
v=ustar+randn(N+1,1);

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

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