help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: set no value to []?


From: Etienne Grossmann
Subject: Re: set no value to []?
Date: Mon, 06 Nov 2000 08:55:23 +0000
User-agent: WEMI/1.13.7 (Shimada) FLIM/1.13.2 (Kasanui) Emacs/20.7 (i386-debian-linux-gnu) (with unibyte mode)

  Hello,

From: Daniel Heiserer <address@hidden>
#  Despite matlab incompatibility and  
#  incompatibiltiy to current m-files
#  is there  another reason for not
#  setting values of a function which
#  are undefined to []?

  [] may be a valid argument. I often use 'nan' where you use [], for
that reason. 'Nan' could be a valid argument for some functions too,
of course.

#  Assume I have a function
#  #----
#  function [o1,o2,o3,o4]=django_1(i1,i2,i3,i4)
#  #....
#  #------

#  And I want to call it whith lets say no value for i2.
#  Currently I have to mess around with nargin and so on.
#  But if I want to be able to call this function 
#  with no i2 OR no i3 and the parameters are of the same
#  type it is hard to impossible to distinguish if I tried to
#  call without i2 or i3.

  You can use option-like arguments, but that's slow : 

  [o1,dummy,o3,o4] = django_1 (i1, i2, "i4", i4);
                                        ^    ^
                                 "Option"    Argument

  I have a "read_options" script for that, but it is clumsy.
                                           

#  Assume omitting i2 gives no result for o2 and omitting
#  i3 gives no result for o3:
#  I think it would be MUCH cleaner then to call the function 
#  then like
#  [o1,,o3,o4]=django_1(i1,,i3,i4);
#     --                  --

  In that case, you could use variable length return list. Function
could be declared as : 

  [...] = django (i1,i2,...)

  and then use vr_add ().

  Cheers,

  Etienne



-------------------------------------------------------------
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
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]