A = [ 0 1 0 ; 0 0 1 ; 1 -3 3 ];     % companion matrix, with minimal 
                                    % polynomial p(z)=(z-1)^3=z^3-3z^2+3z-1   
f=zeros(3,1); f(1)=1;               % right-hand side vector equal to e1 
u0=zeros(3,1);                      % initial guess for gmres
[u,uk,res]=GMRES(A,f,u0,1e-16,3);   % solve using gmres
plot(0:3,res,'o-b','Linewidth',2);  % plot gmres residuals
grid on;                            % switch grid on
xlabel('iterations');
ylabel('residual');
set(gca,'fontsize',14);             % enlarge the size of the text