Multiple plot on same graph
Mostrar comentarios más antiguos
I would like to have these 4 plots on the same graph sheet for easy comparison. Plotting the individual plot works but I am not sure what is the reason why all the 4 plots cannot be plotted at the same time. Relying on benevolent members for assitance.
rng default
n = 30;
% generate the A matrix
D = delsq(numgrid('L',n)); %same as matrix A
bGrid = ones(length(D),1); %same as RHS b vector
M = diag(diag(D));
tol = 1e-8;
maxit = 100;
P = inv(M);
L = ichol(M);
Q = ichol(M,struct('michol','on'));
% pcg
[x0,f0,r0,it0,rv0] = pcg(D,bGrid); %no precond
[x1,f1,r1,it1,rv1] = pcg(D,bGrid,tol,maxit,P); % inv
[x2,f2,r2,it2,rv2] = pcg(D,bGrid,tol,maxit,L,L'); % ichol
[x3,f3,r3,it3,rv3] = pcg(D,bGrid,tol,maxit,Q,Q'); % modified ichol
% plots on same graph
semilogy(0:length(rv0)-1,rv0/norm(bGrid),'-o')
hold on
semilogy(0:length(rv1)-1,rv1/norm(bGrid),'-o')
semilogy(0:length(rv2)-1,rv2/norm(bGrid),'-o')
semilogy(0:length(rv3)-1,rv3/norm(bGrid),'-o')
yline(tol,'r--');
legend('No Preconditioner', 'inv(M)', 'ichol(M)', 'michol(M)', 'Tolerance', 'Location','southwest')
title('Conjugant Gredient Algorithm');
legend('boxoff')
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Sparse Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

