-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrun_example4.m
More file actions
46 lines (34 loc) · 792 Bytes
/
run_example4.m
File metadata and controls
46 lines (34 loc) · 792 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
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] = example4(n);
% Error 1:
err1(n) = norm(myeval(u, xx) - sol(xx), inf);
% Error 2:
n11 = ceil(1.1*n);
u2 = example4(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, 1.8]), grid on
drawnow, shg, pause(eps)
print -depsc2 ../figures/example4a
figure(2) % Error
semilogy(nn, err1(nn), '-', nn, err2(nn), '--');
xlim([0, n])
ylim([1e-21, 1e1])
grid on
drawnow, shg, pause(eps)
print -depsc2 ../figures/example4c
figure(3) % Spy
spy(A)
drawnow, shg, pause(eps)
print -depsc2 ../figures/example4d
alignfigs