-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_res.m
More file actions
42 lines (36 loc) · 846 Bytes
/
plot_res.m
File metadata and controls
42 lines (36 loc) · 846 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
y = A(1,1);
x=1:500;
semilogy(x,y*ones(size(x)))
hold on
fileID = fopen('CGresiduals.txt','r');
formatSpec = '%f %d';
sizeA = [2 Inf];
A = fscanf(fileID,formatSpec,sizeA);
fclose(fileID);
xCG = A(2,:);
yCG = A(1,:);
semilogy(xCG,yCG,"r*");
hold on
fileID = fopen('GMRESresiduals.txt','r');
formatSpec = '%f %d';
sizeA = [2 Inf];
A = fscanf(fileID,formatSpec,sizeA);
fclose(fileID);
xGMRES = A(2,:);
yGMRES = A(1,:);
semilogy(xGMRES,yGMRES,"k.");
hold on
fileID = fopen('GMRESrestart.txt','r');
formatSpec = '%f %d';
sizeA = [2 Inf];
A = fscanf(fileID,formatSpec,sizeA);
fclose(fileID);
xrestart = A(2,:);
yrestart = A(1,:);
semilogy(xrestart,yrestart,"x");
curtick = get(gca, 'xTick');
xticks(unique(round(curtick)));
xlabel('Iteration')
ylabel('Norm of Residual')
legend('Gaussian elimination','CG','GMRES');
saveas(gcf,'struc500','epsc')