-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExampleC.m
69 lines (64 loc) · 2.05 KB
/
ExampleC.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
58
59
60
61
62
63
64
65
66
67
68
69
close all
clear all
% Add directory to current path
addpath('..')
% Parameters
n = 4-1; % Number of interfaces
sigma = sqrt([.2, .01, .1, 1.]); % Diffusivities
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, 1]; % Boundary conditions
f1 = @(t) cos(t); % LHS Boundary condition
f2 = @(t) 0.; % RHS Boundary condition
tspan = [0.5,1,2,10]; % Times at which to compute solution
options.NX = 15; % 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))-.1,max(max(u))+.1],'Color',[0.9,0.9,0.9])
hold on
end
for j=1:length(tspan)
plot(xf,u(:,j),'r-','LineWidth',2.0)
end
axis([0,1,-1,1.1])
xlabel('$x$','Interpreter','LaTeX','FontSize',20)
ylabel('$u(x,t)$','Interpreter','LaTeX','FontSize',20)
set(gca,'FontSize',14,'Layer','top')
saveas(gcf,'ExC.pdf')
for j=1:length(tspan)
figure
for i = 1:n+1,
plot([xj(i),xj(i)],[min(min(u))-.1,max(max(u))+.1],'Color',[0.9,0.9,0.9], 'LineWidth',1.)
hold on
end
plot(xf,u(:,j),'r-','LineWidth',2.0)
axis([0,1,-1,1.1])
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')
filename=['ExC_t', num2str(tspan(j))];
filename(filename==['.'])=[];
saveas(gcf,[filename '.pdf'])
end
%%For Paper
figure;
for i = 1:n+1,
plot([xj(i),xj(i)],[min(min(u))-.1,max(max(u))+.1],'Color',[0.9,0.9,0.9])
hold on
end
for j=1:length(tspan)
plot(xf,u(:,j),'r-','LineWidth',2.0)
end
axis([0,1,-1,1.1])
ax=gca;
ax.XTickLabel={};
ax.YTickLabel={};
saveas(gcf,'ExC_p.pdf')