function sample
global N L
N = 51;L = 2*pi*wn;x = linspace(0,L,N);
st=10;ft=100;t = 0:st:ft;fin=ft/st;
y0 = 1-0.1*cos(x);
e = ones(N,1);S = spdiags([e e e e e], -2:2,N,N);
options = odeset('RelTol',1e-4,'AbsTol',1e-20, 'JPattern',S,'BDF','on');
[t,h] = ode23tb(@r,t,y0,options);
plot(x,h(fin,:),x,h(1,:),'--','LineWidth',2)
axis([0 L 0 2])
function yt = r(t,y)
global N L
yt0=size(N);
dx = L/(N-1);a2=-1/(2*dx^4);
r1=y.^2;
y(N+1) = y(2);y(N+2) = y(3);r1(N+1) = r1(2);
for i = 3:N
yt0(i)=a2*(r1(i+1) + r1(i))*(y(i+2)-3*y(i+1)+3*y(i)-y(i-1))-...
a2*(r1(i) + r1(i-1))*(y(i+1)-3*y(i)+3*y(i-1)-y(i-2));
end
hm=y(N-1);hmm=y(N-2);r1m=r1(N-1);
i=1;
yt0(i) = (a2*(r1(i+1) + r1(i))*(y(i+2)-3*y(i+1)+3*y(i)-hm)-...
a2*(r1(i) + r1m)*(y(i+1)-3*y(i)+3*hm-hmm));
i=2;
yt0(i) = (a2*(r1(i+1) + r1(i))*(y(i+2)-3*y(i+1)+3*y(i)-y(i-1))-...
a2*(r1(i) + r1(i-1))*(y(i+1)-3*y(i)+3*y(i-1)-hm));
yt = yt0';