help-octave
[Top][All Lists]
Advanced

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

Re: fzero


From: Clinton Winant
Subject: Re: fzero
Date: Fri, 1 Apr 2016 15:53:56 -0700

I have checked the behavior of fzero in octave and matlab and found them to be pretty consistent except for some easy to understand differences: for instance the program

>>         f = @(x,c) cos(c.*x);  % The parameterized function.
>>          c = 2;                 % The parameter.
>>          X = fzero(@(x) f(x,c),0.1)

returns X = -0.78540 in octave and X =    0.7854 in matlab (sign difference). Both solutions are correct.  The behavior when the initial bracket is invalid is slightly different between the two languages, but no majot problem.

The main issue with the octave version is the documentation:  in matlab "help fzero" returns several examples of calls to fzero (not all of which are correct), whereas the octave documentation includes no such example.  Given the complexity of anonymous function definition and terminology such at @(x), it might be useful to include an example such as the one above.



On Thu, Mar 31, 2016 at 12:32 PM, Clinton Winant <address@hidden> wrote:
Olaf Thanks so much.  I have never used try-catch, now I will.  I have to wait to get on someone elses machine to use matlab, cant afford it myself.  I will do so later today and report.   I am so grateful to people like you.  You make my work possible!

Clinton Winant

On Thu, Mar 31, 2016 at 10:35 AM, Olaf Till <address@hidden> wrote:
On Thu, Mar 31, 2016 at 10:12:49AM -0700, Clinton Winant wrote:
> Is there any way to make the termination
>  fzero: not a valid initial bracketing
> not fatal?

There is no such way ... except, of course, running in a try-catch
block (one could examine the error message with lasterr() then).

> I have read the help fzero section about returned values info
> and output but see no flag that could be tested so that the x0 array can be
> modified for a retry w/o terminating the script?

The reason could be that Matlab also does not set a flag for
this. (Maybe you can say what Matlab does in this case?)

Olaf

--
public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net



reply via email to

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