From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Problem
Date: Thu, 6 May 2010 15:47:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 11
Message-ID: <hruo9p$ocp$>
References: <hrqe77$jcs$> <> <>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1273160825 24985 (6 May 2010 15:47:05 GMT)
NNTP-Posting-Date: Thu, 6 May 2010 15:47:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:633196

TideMan <> wrote in message <>...
> But Roger, doesn't your fancy algorithm reduce to central finite
> differences if the x are equispaced:
> dydx(2:end-1)=(y(3:end) - y(1:end-2))/(2*dx);
> without the pretty stuff at the ends of course.

  Yes, of course, for equally-spaced x values.  In that case one can obtain the same answers from the single-dimensional version of the 'gradient' function except for the endpoints, which are not properly done in my opinion.

  For variable-spaced x's the 'gradient' function does not use weighted averages, so it is not actually a second order approximation in that circumstance.  That is, it does not get exact derivatives for quadratic functions if the x intervals are variable - at least not in my version.

Roger Stafford