Recall a sub function with multiple outputs?

2 views (last 30 days)
I am writing a code to calculate a decay rate. In one of the sub functions, I wrote:
[x, iter] = bis (a,b,tol,L)
so when I use this sub function in my code, for instance:
k = bis (a,b,tol,L)
i will get a "k", but what exactly is k? And if I only want k = iter.. what should I write in my code so that k = iter?

Accepted Answer

the cyclist
the cyclist on 19 Sep 2015
Edited: the cyclist on 19 Sep 2015
If you only want the 2nd output, write this
[~,k] = bis (a,b,tol,L)
That little tilde (~) is effectively ignoring that first output, in the calling function.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!