help-octave
[Top][All Lists]
Advanced

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

Re: problems


From: fbarbuto
Subject: Re: problems
Date: Thu, 1 Oct 2015 12:20:10 -0700 (PDT)

Hi Robert,

You might write your function hyp() like this:

function r = hyp(x=0,y=0)
  r = sqrt(x*x + y*y);
end

That would prevent execution errors should you pass no arguments to it
(which would be a bit of a
nonsense, though):

>> hyp
ans = 0
>> hyp()
ans = 0
>>

But it would work fine with some arguments:

>> hyp(3)
ans =  3

>> hyp(4)
ans =  4

>> hyp(3,4)
ans =  5

HTH,

Fausto





--
View this message in context: 
http://octave.1599824.n4.nabble.com/problems-tp4672714p4672736.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

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