%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%EQ Chaleur 1-d
%
%Theta-schema
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all

        %Données numériques en temps et en espace

n=100;h=1/(n+1);x=h:h:1-h;
dt=0.01;Npdt=1000;
theta=0.5000;
        % matrices
        A=gallery('tridiag',n)/h^2;
       
        M=speye(n,n)+theta*dt*A;
        N=speye(n,n)-(1-theta)*dt*A;
        %factorisation de cholesky
        S=chol(M);
        %initialisation
        f=ones(n,1);
        U=rand(n,1);;
        %$$$$$$$$$$$$$$$$$$$$$$$$$$$
        %Boucle en temps
        %$$$$$$$$$$$$$$$$$$$$$$$$$$$
        k=0;
        while k < Npdt
            V=S'\(N*U+dt*f);
            U=S\V;
            plot(x,U)
            drawnow
            k=k+1;
        end