1

I am using this pcg function in matlab. However it outputs the iteration message like this

pcg converged at iteration 5 to a solution with relative residual 9.3e-07.

I want to suppress this message. I have found that I can suppress this message with the flag option in the output. So if I do something like this

[x flag] = pcg(...)

it suppresses the output. However, I cannot do that in my case. Is there any other way. When I went through the code of pig, I could see that it prints the message using itermsg function. Is there any way to suppress this function?

user31641
  • 165
  • 1
  • 7
  • 1
    So you can't use `[x,~]=...` either? Are you using this in an anonymous function? Is that why you can't have more than one output? How about creating a helper function to capture the output? And you could always edit the code for `pcg` (or `private/itermsg`) or create your version. There doesn't seem to be any `options` structure as is common with many optimization functions. – horchler Jan 25 '14 at 18:24
  • Some options [here](http://stackoverflow.com/questions/3029636/suppressing-a-functions-command-window-output), but I don't think the `evalc` one will work for you because of the order of it's output arguments. – horchler Jan 25 '14 at 18:35
  • can't you just in the code comment the message line? using % – NKN Jan 25 '14 at 18:37

1 Answers1

0

You can do it with a helper function,

function [x,flag,relres,iter,resvec] = pcg_quiet(varargin)
[x,flag,relres,iter,resvec] = pcg(varargin{:});

The function pcg_quiet will act identitcal to pcg, except without the text. For example,

>>> x = pcg_quiet(A,b);
Nick Alger
  • 984
  • 7
  • 26