Untitled

                Never    
function project

L=2*pi;
tmax = 6;
x=0:0.00005:L;
t=0:tmax/100:tmax;

function y=phi(x)

for i=1:length(x)
    if x(i)>=2 && x(i)<=3 %x is in [2,3]
        y(i) = 2*(x(i)-2)^3*(cos (x(i)*pi/6))^3;
    else
        y(i)=0;
    end
end
end


function y=u(x,t) %function for our solution

y = 0;

for k=0:49 % 50 partial amounts
    Xk=sin((2*k+1)*x/4); % own functions
    Ak=trapz(x, phi(x).*Xk)/pi;
    Tk=Ak*exp(-((2*k+1)/4).^2*t/6);
    y=y+Tk*Xk;
end

end

for n=1:length(t)
    plot(x,u(x,t(n)))
    axis([100,100,-1000,10])
    %daspect([1,1,1])
    
    M(n)=getframe;
end

movie(M,1)

subplot(3,1,1)
plot(x,u(x,0))
title('Subplot for t=0') %0
axis([0,2*pi,-3,3])

subplot(3,1,2) %3.1.1
plot(x,u(x,3))%1 vmesto 1/2
title('Subplot for t=3') %1
axis([0,2*pi,-3,3]) %0.7

subplot(3,1,3)
plot(x,u(x,6)) %2
title('Subplot for t=6') %2
axis([0,2*pi,-3,3])

end

Raw Text