jason
jason

Reputation: 2106

How to disable the display from a function in MATLAB

A function gradient() is writed by some developer, and I try to call it in my main() function. However, inside the gradient(), it will print some message as following:

Total time is 0.045420 [s] (excludes statsfun) iter                cost val     grad. norm
0   -2.1794659039050758e+08 4.47344788e+08
1   -5.9276958454539728e+08 3.03276019e+08
2   -6.3078232706850171e+08 1.47674763e+08
3   -6.3981329944849074e+08 7.63431416e+07
4   -6.4251920114089453e+08 5.53428795e+07
5   -6.4558893912953174e+08 5.07800110e+07

How to disable display those message from the gradient() ?

Upvotes: 0

Views: 66

Answers (1)

Edric
Edric

Reputation: 25140

Short of editing gradient.m, you can always fall back on evalc as a last resort. So, instead of writing

[out1, out2] = gradient(in);

You'd write

[~, out1, out2] = evalc('gradient(in);');

Upvotes: 2

Related Questions