[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to use varargout?
From: |
Terry Duell |
Subject: |
How to use varargout? |
Date: |
Fri, 08 Aug 2014 14:25:11 +1000 |
User-agent: |
Opera Mail/12.16 (Linux) |
Hello All,
I want my function to have a variable number of output parameters, and it
looks as though one must use sequential parameters, and not 1,3,4,6 for
example.
To illustrate what I mean, say my function is...
function varargout = myfunc(a,b,c)
% outputs can be [a1, a2, a3, a4, a5, a6]
% where a1 = ...
% a2 = ...
if nargout == 1
stuff = a1
else
otherstuff = a2
etc
so, is it possible to call myfunc as follows;
[b1,,b3,,b5] = myfunc(a,b,c)
where I'm looking to output a1, a3, and a5 only?
I realise that the syntax, above, throws an error, so I'm looking for the
right way to do it, if it can be done.
Cheers,
--
Regards,
Terry Duell
- How to use varargout?,
Terry Duell <=