-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrun_example2.m
More file actions
47 lines (35 loc) · 814 Bytes
/
run_example2.m
File metadata and controls
47 lines (35 loc) · 814 Bytes
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
close all
set(0, 'DefaultLineLinewidth', 2)
xx = linspace(-1,1,100);
nn = 2:20;
err2 = 0*nn; err1 = err2;
for n = nn
% Solve for each n:
[u, A, sol] = example2(n);
% Error 1:
err1(n) = norm(myeval(u, xx) - sol(xx), inf);
% Error 2:
n11 = ceil(1.1*n);
u2 = example2(n11);
err2(n) = norm((u - u2([1:n, n11+(1:n)])), 2);
end
%%
% Plotting:
figure(1) % Solution
plot(xx, myeval(u, xx));
ylim([0, 1]), grid on
drawnow, shg, pause(eps)
print -depsc2 ../figures/example2a
figure(2) % Error
semilogy(nn, err1(nn), '-', nn, err2(nn), '--');
xlim([0, n])
ylim([1e-16, 1e1])
grid on
drawnow, shg, pause(eps)
print -depsc2 ../figures/example2c
[u, A, sol] = example2(100);
figure(3) % Spy
spy(A)
drawnow, shg, pause(eps)
print -depsc2 ../figures/example2d
alignfigs