-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplots.m
49 lines (39 loc) · 1009 Bytes
/
plots.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
exact = readmatrix('exact.txt');
solution = readmatrix('solution.txt');
variables = readmatrix('variables.txt');
exact = exact(:, 1:end-1);
solution = solution(:, 1:end-1);
xmax = variables(1);
dx = variables(2);
dt = variables(3);
a = variables(4);
T = variables(5);
x = linspace(0, 2*pi, xmax);
time = 0.1:dt:T-dt;
figure
plot(x, exact(1, :), x, solution(1, :))
legend('exact', 'solution')
t = 0
figure
for i = 1:length(0.1:dt:T)-1
t = t + dt;
test = sin(x).*exp(-a*t);
plot( x, solution(i, :), '-*', x, exact(i, :), 'k')
error(i) = norm(exact(i, :) - solution(i, :), 1);
ylim([-1, 1])
legend( 'exact', 'solution')
grid on
drawnow
end
figure
semilogy(time, error)
j = 0;
while(j < 1.0)
j = j + 0.1
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% CUDA test
cudaSolution = readmatrix('cudaSoln.txt');
cudaSolution = cudaSolution(:, 1:end-1);
figure
plot(x, cudaSolution, x , exact(1, :));