[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: setting defacult values for input parameters in functions
From: |
Martijn Brouwer |
Subject: |
Re: setting defacult values for input parameters in functions |
Date: |
Tue, 19 Oct 2004 09:38:10 +0200 |
With nargin() you can determine the number of input arguments of a
function. Depending on the number of input arguments you can give a, b
and c a default value.
if nargin < 3
c=
end
if nargin < 2
b=
end
if nargin < 1
a=
end
The only drawback is that you assume that when one argument is given, it
will be a, and when there are two, it will be a and b.
For my use, this approach suffices.
Martijn
On Tue, 2004-10-19 at 12:49 +0530, Y U Sasidhar wrote:
> function y = f(a,b,c)
> body
> endfunction
>
> is it possible to set default values to a, b, c ? or some of
> them ?
--
Martijn Brouwer <address@hidden>
University of Twente
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------