From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: tangent line from curve graph
Date: Sun, 22 Feb 2009 03:16:01 +0000 (UTC)
Organization: Battelle Energy Alliance (INL)
Lines: 28
Message-ID: <gnqg1h$dg8$>
References: <gnq5ll$bih$> <gnq6hq$amn$> <gnqcsa$cnb$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: 1235272561 13832 (22 Feb 2009 03:16:01 GMT)
NNTP-Posting-Date: Sun, 22 Feb 2009 03:16:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 688530
Xref: comp.soft-sys.matlab:519952

"Stephen " <> wrote in message <gnqcsa$cnb$>...
> Thanks for response, Matt Fig.
> I really not good in matlab, so can u explain a little bit about forward difference, backward difference and secant. I'm not really understand.

Those aren't terms specific to Matlab.  I was talking about numerical derivative approximations.   See this link:
For example, say we have two vectors:
x = 0:.1:pi;
y = sin(x);  % Pretend we don't know it is sin(x) for arguments sake.
idx = find(x==1) % We will find the derivative at x = 1;
Because the slope is decreasing at x=1, the forward difference will underestimate the derivative:
while the backward difference will overestimate the derivative:
The secant difference is the average of these:
Compare these estimates with the true derivative:

> I already tried spline, but seems it shows the values of P, not dP/dt.
> Maybe i wrong in giving information earlier but what i wish to obtain is the value of dP/dt at specified t and in my mind, this value can be obtained by finding tangent line (or slope) at that specified t.
> Meaning that, the tangent (or slope) should represents as dP/dt.
> Sorry,if i already misunderstood your opinion.

The idea with the polynomial fit is that it is easy to take the derivative of a polynomial.  You fit a polynomial to the data, over some region of interest, then take the derivative of the polynomial.  If the fit is very good, the derivative should be o.k.  Things can go wrong with this method too, that is why numerical differentiation is tricky.