MATLAB: Get only one output from a function with several ones

functionoutput

Suppose I define a function:
function [A,B] = myfun(x,y,z)
...
...
I know that if I type
[C,D] = myfun(1,1,1)
then I'll get both C (corresponding to A) and D (corresponding to B) for the specific values or if I type
C = myfun(1,1,1)
I'll get C (corresponding to A). Is there a way to get only D for these specific values? Thank you in advance!

Best Answer

Yes. You need to use the ‘~’ (in English, tilde) to suppress the outputs you don’t want. So to get only ‘D’, call the function as:
[~,D] = myfun(1,1,1)