-
Notifications
You must be signed in to change notification settings - Fork 1
/
ExampleE.m
57 lines (53 loc) · 1.81 KB
/
ExampleE.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
close all
% Add directory to current path
addpath('..')
% Parameters
n = 200-1; % Number of interfaces
sigma = ones(n+1,1); % Diffusivities
for j=1:n+1;
sigma(j)=sqrt(1.1+sin(j));
end
xj = linspace(0,1,n+2);
xj = xj(2:n+2); % Location of interfaces
u0 = @(x) ones(size(x)); % Initial condition
beta = [1, 0, 1, 0]; % Boundary conditions
f1 = @(t) .5; % RHS Boundary condition
f2 = @(t) 0; % LHS Boundary condition
tspan = [.01,0.1,0.3,5.]; % Times at which to compute solution
options.NX = 10; % Number of places to evaluate solution
options.NN = 10; % Integration bounds
options.Ny = 200; % Number of points to use in integration
tic
[u,xf] = UTM_Heat(n,sigma,xj,u0,beta,f1, f2, tspan,'Perfect',options);
toc
% Plot
figure;
for i = 1:n+1,
plot([xj(i),xj(i)],[min(min(u)),max(max(u))],'Color',[0.9,0.9,0.9])
hold on
end
for j=1:length(tspan)
plot(xf,u(:,j),'m-','LineWidth',2.0)
end
axis([0,1,0,1])
xlabel('$x$','Interpreter','LaTeX','FontSize',20)
ylabel('$u(x,t)$','Interpreter','LaTeX','FontSize',20)
set(gca,'FontSize',14,'Layer','top')
axis([0,1,0,1.01]);
saveas(gcf,'ExE.pdf')
for j=1:length(tspan)
figure
for i = 1:n+1,
plot([xj(i),xj(i)],[min(min(u)),max(max(u))],'Color',[0.9,0.9,0.9], 'LineWidth',1.)
hold on
end
plot(xf,u(:,j),'m-','LineWidth',2.0)
xlabel('$x$','Interpreter','LaTeX','FontSize',20)
ylabel('$u(x,t)$','Interpreter','LaTeX','FontSize',20)
title(['$t=$ ',num2str(tspan(j))],'Interpreter','LateX','FontSize',20)
set(gca,'FontSize',14,'Layer','top')
axis([0,1,0,1])
filename=['ExE_t', num2str(tspan(j))];
filename(filename==['.'])=[];
saveas(gcf,[filename '.pdf'])
end