function ueb2
%
% Matlab-File for the Solution of the Lab Exercise of the 
% 2. Exercise Sheet of the Lecture
% "Numerical Analysis and Simulation II: 
%  Partial Differential Equations (PDEs)"
% M. Ehrhardt, SS 2012
%
% u_t=u_xx, 0<x<1, t>0
%
% u(x,0)=0, 0<x<1
%
% u(0,t)=u(1,t)=12*sin(12*pi*t)^2, t>0
%
clear
close all
                                                   
T=1;   % Endzeit
Nx=21; % Anzahl Gitterpunkte in x 
Nt=73; % Anzahl Gitterpunkte in t

m = 0;
x = linspace(0,1,Nx);
t = linspace(0,T,Nt);

loesung = pdepe(m,@ueb2PDGL,@ueb2AB,@ueb2RB,x,t);
u = loesung(:,:,1);

figure;
surf(x,t,u);    
title(['Numerische Loesung mit ',num2str(Nx),' Ortsgitterpunkten berechnet.']);
xlabel('Ort x');
ylabel('Zeit t');

% Unterroutinen
% --------------------------------------------------------------------------

% c*u_t=u_xx
function [c,f,s] = ueb2PDGL(x,t,u,DuDx)
c = 1;
f = DuDx;
s = 0;

% --------------------------------------------------------------------------

% Anfangsbedingung
function u0 = ueb2AB(x)
u0 = 0*x;

% --------------------------------------------------------------------------

function [pl,ql,pr,qr] = ueb2RB(xl,ul,xr,ur,t)
% links
pl = ul-12*sin(12*pi*t)^2;
ql = 0;
% rechts
pr = ur-12*sin(12*pi*t)^2;
qr = 0;

                    















