```Path: news.mathworks.com!not-for-mail
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\$1@fred.mathworks.com>
References: <gnq5ll\$bih\$1@fred.mathworks.com> <gnq6hq\$amn\$1@fred.mathworks.com> <gnqcsa\$cnb\$1@fred.mathworks.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1235272561 13832 172.30.248.35 (22 Feb 2009 03:16:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 22 Feb 2009 03:16:01 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:519952

"Stephen " <mulan_nuri@yahoo.com> wrote in message <gnqcsa\$cnb\$1@fred.mathworks.com>...
> 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:
http://en.wikipedia.org/wiki/Numerical_differentiation
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:
(y(idx+1)-y(idx))/(x(idx+1)-x(idx))
while the backward difference will overestimate the derivative:
(y(idx)-y(idx-1))/(x(idx)-x(idx-1))
The secant difference is the average of these:
(y(idx+1)-y(idx-1))/(x(idx+1)-x(idx-1))
Compare these estimates with the true derivative:
cos(1)

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