The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Function parameters default value
Replies: 1   Last Post: Jul 27, 2012 12:36 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Lafin Myazov

Posts: 10
Registered: 7/27/12
Re: Function parameters default value
Posted: Jul 27, 2012 12:36 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Earlier today, usenet's grand fumblewit Christopher wrote:

> I like to use:
> function foo = fx(arg1,arg2)
> if ~exsit('arg1','var')
> arg1 = 'default value';
> end
> that way if the user types:
> foo = fx(,'bar'); %user intentionally omits first parameter in call to
> fx.
> the program will assume arg1 as 'default value'.
> I don't like to check with varargs nargs etc, because this can force
> particularities in parameter order when I don't want that (in general).

hmmm... I doubt my version of Matlab has a parameter named "exsit".
Perhaps it's a hidden feature.

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.