f

#### tangent line from curve graph

```hi friends,
i need your help. I wish to do tangent line from curve graph plotted.
I have data for P at time,t. Then, i plot the graph of P against t which shows it is curve line. By using only this graph, how can i do tangent line at specific t in order to obtain value for dP/dt?? In addition, no equation for P is available.

```
 0
2/22/2009 12:19:01 AM
comp.soft-sys.matlab 211266 articles. 15 followers. lunamoonmoon (258) is leader.

5 Replies
667 Views

Similar Articles

[PageSpeed] 6

```At point n, you could find the forward difference or the backward difference or take a secant from n-1 to n+1.  For example:

dy/dx ~ [P(n+1) - P(n)] / [(n+1) - n]

Alternatively, you could fit a polynomial or spline and take it's derivative at that point.  There are many ways to approximate the derivative.
```
 0
spamanon (2437)
2/22/2009 12:34:02 AM
```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.
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.

```
 0
2/22/2009 2:22:02 AM
```"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.
>

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.
```
 0
spamanon (2437)
2/22/2009 3:16:01 AM
```"Stephen " <mulan_nuri@yahoo.com> wrote in message <gnq5ll\$bih\$1@fred.mathworks.com>...
> hi friends,
> i need your help. I wish to do tangent line from curve graph plotted.
> I have data for P at time,t. Then, i plot the graph of P against t which shows it is curve line. By using only this graph, how can i do tangent line at specific t in order to obtain value for dP/dt?? In addition, no equation for P is available.
>

If you are willing to do additional computation, you can approximate the derivative (slope) at each point with the following second order differencing.  Suppose t and p are n-element row vectors.  (The stuff below can easily be adjusted for column vectors.)  Then do this:

td = [t(3),t(1:n-1)]; tu = [t(2:n),t(n-2)];
pd = [p(3),p(1:n-1)]; pu = [p(2:n),p(n-2)];
dpdt = ((pu-p)./(tu-t).*(t-td)+(p-pd)./(t-td).*(tu-t))./(tu-td);

Then dpdt will be an n-element row vector of corresponding derivative approximations of dp/dt.  The fact that it is a second order approximation means that if you make p any linear or quadratic function of t, the quantity dpdt is an exact derivative at each of the points.  Note that the t-intervals need not be equally-spaced for this to be true.  Note also that this property holds even for the two endpoints.

There are also some higher order derivative approximations on the file exchange, probably listed under the term "gradient".

Roger Stafford
```
 0
2/22/2009 4:50:18 AM
```Thanks to Matt Fig and Roger Stafford.
You have give me some valuable ideas on what should i do. just i need to further study about that. I have studied before but already forgotten. ;P

Thanks again!!
```
 0
2/22/2009 9:46:02 AM

Similar Artilces:

How I can find the slope of a tangent line and plot that tangent line in matlab
Hello every one.I have the follwing problem. I must write a function script to find the tangent line for the function f(x)=(A.*(x.^3))+B.*(x.^2)+(C.*x)+D. Executing the scriptfile must create a plot with f(x) including the tangentline at the specific point. Work only from the schedule below: &#8226;The syntax of the function definition line, must be as follows: function[slope]=tangentline(A,B,C,D, x, Location) &#8226; A,B,C,D : These are the coefficients of the polynomial function. &#8226; x :This is the name of the independent internal variable.x must be defined before c...

tangent line to a curve
Hi Matlab's users I need help with the following problem: I have a curve from a measurement data set I need to find the intercept, of the tangent to this curve, with the x-axis, The tangent to the curve must be calculated in the point of the curve where the derivative of this curve have the maximum values. Other way to explain : I want to find a tangent to a curve where this curve have the maximun slope, or where it's own derivative is maximum, then i need the intercept of the tangent with the x-axis thanks in advance Stefano Stefano wrote: > > Hi Matlab's users > I ...

graphing tangent lines
I am just starting to use Matlab, and I am lost! How do I do this? I need to graph the equation y=(x+1)/(x-1) and include a domain of (-4,4) and range of (4,4). Also I need to have the tangent lines at points (2,3) and (-1,0). How do I do this? The code would be very helpful. I can get the graph with fplot...but i cant get the tangent lines. Linspace confuses me...please hep! In article <ef13d6e.-1@webx.raydaftYaTP>, "Luke Bickston" <laterdaysluke@yahoo.com> wrote: > I am just starting to use Matlab, and I am lost! How do I do this? I > need to graph the equation ...

curved lined on matlab plot
Hello can anyone tell me how can i make plot lines look curved? i have some points and when i make a plot the lines are straight but i want curved lines. Is there a command to do this for me? thank u On 4/25/2013 7:25 PM, chimi wrote: > Hello can anyone tell me how can i make plot lines look curved? >i have some points and when i make a plot the lines are straight >but i want curved lines. Is there a command to do this for me? > thank u > Look at spline() for cubic poly, or for general case, look at using interp. --Nasser "Nasser M. Abbasi" wro...

Tangent Lines of Two Curves
My group and I are working on creating a binary phase diagram (eventually a ternary). We were told that there is a function in MatLab that will find a common tangent between two curves or something similar to that. However we can't find the coding that would be used to take a tangent of a line. Any help is GREATLY appreciated. -Nick Martinez Nick Martinez wrote: > > > My group and I are working on creating a binary phase diagram > (eventually a ternary). We were told that there is a function in > MatLab that will find a common tangent between two curves or > something s...

Displaying graphs with curved lines
Hi all, First post, though I've been lurking for a bit. I thought I'd share with everyone a modification I made to the Combinatorica package to allow for the display of curved edges in graphs displayed with ShowGraph[]. Unfortunately this isn't terribly robust, employs the Splines package, and is appropriately filed under "hack", but it works well enough and is very, very simple. We'll be piggy-backing on the EdgeDirection option already built into Combinatorica Graph objects; this guy is Boolean, but we'll be giving it a numerical value so as to duck...

slope of the tangent line of a curve
Hi, I am trying to find the slope a tangent line to a curve at a given x. I have a matlab plot with twelve curves on it and need to find the slope of each curve at a given x. Any idea how I can do this? Thanks in advance! On 4/10/2013 9:31 AM, Yashesvini wrote: .... > I am trying to find the slope a tangent line to a curve at a given x. > > I have a matlab plot with twelve curves on it and need to find the slope > of each curve at a given x. Any idea how I can do this? .... doc gradient % for starters... One can also do things like fit and the compute analytic result from splines, etc., ... How exotic you need to get will depend on the shape of the curves, how well sampled your data points, how good an estimate you need, etc., etc., etc., ... -- ...

Tangent line to French Curve
Greetings, <http://mathworld.wolfram.com/FrenchCurve.html> Can somebody explain the second paragraph? I understand all the facts presented (or so I think) but it eludes me how the derivative of the curve at any point along that curve could be zero. It would seem to me that for any given orientation, only a few points on that curve are at the maximum or minimum positions. Is sneaky wording at play? "Sean Hamilton" <sh@planetquake.com> wrote in message news:hvn9b.11264\$Cu3.10166@edtnps84... > Greetings, > > <http://mathworld.wolfram.com/FrenchCurve.ht...

Getting a tangent line to a curve
Howdy, I need help with how to solve this problem with matlab. I have a given equation to a curve and I need to find an equation of the tangent line to that curve at a specific point. I then need to graph it with that specific point showing as an open circle. How can I do this? I already know the basic process, aka: -get the derivative of the curve -plug the x coordinates into F'(x) to get the slope -use y-y_1=m(x-x_1) to find the total equation I already know how to get F'(x) using the diff command. I just don't know what commands and such to use, I have no computer...

Bar graph and line graph
I have a bar graph, and would like to transform it in a line graph, like this: http://i26.tinypic.com/30jnw1w.jpg The x dots are the middle value of each bar. Is there a function that does that? Fernando Yuji Ono <fernando90ono@gmail.com> wrote in message <159055510.6162.1278780771291.JavaMail.root@gallium.mathforum.org>... > I have a bar graph, and would like to transform it in a line graph, like this: > > http://i26.tinypic.com/30jnw1w.jpg > > The x dots are the middle value of each bar. Is there a function that does that? a hint: help sta...

two line in line graph
Hi, I am using v18 SPSS and I would like to ask, if it is possible to have two lines in one graph (very easily done in Excel, but I cannot find this in SPSS). I have two time series and I would like them both in one graph, to be able to see the comparison (total cost nominal, total cost real). how can this be done. I cant find the way to use multiple line graph option... can someone please give me some advice? thank you so much... tom On May 3, 5:25=A0am, xbender <xben...@gmail.com> wrote: > Hi, > > I am using v18 SPSS and I would like to ask, if it is possible ...

How to make a line straight from a curved line
I am using PSP 8. I have a box that for some reason has a slight curve on the bottom line (not sure why). I was only able to get it straighten out by adding about 15 nodes along the line and move each one at a time to line it up. The problem is if I delete any of the nodes ( I want to shorten the line and need to delete the nodes to do this), the line starts to curve again. Is there a way to quickly straighten the line and keep it that way? Also, to to get the program allow me to edit my object, I need to go to the object selection tool before going to the pen tool. I can then add nodes ...

How to make a line straight from a curved line
I am using PSP 8. I have a box that for some reason has a slight curve on the bottom line (not sure why). I was only able to get it straighten out by adding about 15 nodes along the line and move each one at a time to line it up. The problem is if I delete any of the nodes ( I want to shorten the line and need to delete the nodes to do this), the line starts to curve again. Is there a way to quickly straighten the line and keep it that way? Also, to to get the program allow me to edit my object, I need to go to the object selection tool before going to the pen tool. I can then add nodes ...

how to draw pie graph or line graph
Hi frnds, I want to draw pie graph or line graph through javascript. Can anyone give me a sample code for these charts. Thank you Dinesh And if you can Top Coder has a \$1,600 contest running for right now...Submissions due by Friday. JRS: In article <1156946063.862200.79610@i3g2000cwc.googlegroups.com>, dated Wed, 30 Aug 2006 06:54:23 remote, seen in news:comp.lang.javascript, balakrishnan.dinesh@gmail.com posted : > I want to draw pie graph or line graph through javascript. >Can anyone give me a sample code for these charts. <URL:http://www.merlyn.d...

MS Graph 8 Line Graphs
By default, series lines on line graphs don't appear between points that have null values between them. Ie, if one series has values for a, b and c, while the second series only has values for a and c; the first series will have all it's dots connected while the second will not. I believe there is a setting to change this so the lines render between such "orphan" points. Can someone please tell me where this is? :) ...

Changing Line Graph Colors in Microsoft Graph
Anyone know a way to change the colors used for the lines of a line graph in a Microsoft Graph Chart (Access 2003)? Some of the very-light colors they use are barely readable! TIA! Neil ...

modify a line in a line graph using code
i need to modify a specific series, line weight and color. however, i need to specify the series number, which can change. how can i translate or set the series name (object) to the number? ...

multiple line graphs on single graph window
hi, I want to draw two row vectors, say: A=[2 3 4 5], B=[6 7 5 4] by using plot commond. I need to see both on the same graph, for comparitive analysis. I am not talking about subplot. thanks Erik L wrote: > I want to draw two row vectors, say: > > A=[2 3 4 5], B=[6 7 5 4] > by using plot commond. > > I need to see both on the same graph, for comparitive analysis. I am not > talking about subplot. plot(1:length(A),A,'o',1:length(B),B,'+'); Or plot(A,'o'); line(1:length(B),B,'+'); %hold on is NOT needed...

get title line on a multi-line graph
hello, my problem look like that: I have some file which I called 01.dat,02.dat,03.dat,04.dat...... in each file I have two column of data (temperature and deep) which I'd like to plot... For plotting it I've no problem, I get all the curve on one graph but the thing is, that, now I would like that when I click with the mouse on one curve it tells me what is the title of my curve.... I've try to put a tag on my curve but it doesn't work... and the function clabel can not work either for this kind of graph how can I do which function can I use thank you very much remy remy ...

How to make a graph tangent to tops of another graph?
Hi, I've got a graph; the velocity as the function of the rpm of car, the actual graph consists of 4 subgraphs (one for each of the 4 gears of the car) I conjoined those sub-graphs with a for loop and some if statements. This resulting graph looks like a ball which bounces to the ground(parabola's). I need to add a graph which is tangent to all the tops of the graphs. This would look like a hyperbola touching the tops of the original graph then. Pity I can't display a picture which shows what i'm trying to achieve. I hope someone can help me. Cheers To clarify what i...

MATLAB 3D Graph to SAS 3D Graph
Hello: I would like to generate a 3D graph in SAS. The points are (x,y,z). I would like to have a SCATTER plot on the (x,y) axes. But then each one of these (x,y) points are LINE connected to their respective z point. If anyone has code for this, or know how to do this in SAS, it would be so helpful. Thx!! I tried to attach the graph as a visual as part of my question, but apparently we cannot send .gif. ...

Draw a curved cylinder around a curved line?
Hi all: I have a matrix included x y z coordinates of a curved line in 3D space. How can I draw a curved cylinder around this line. I think streamtube might be a good idea, but I dont know how I can change the x y z coordinates to use this syntax. Pl help. ...

execute script line by line in the matlab editor
Hi, Is there a quick way do execute script line by line in the matlab editor by key board? Suppose I prototyped 10 lines of matlab code and there are not in a function. I would like to step through them one by one and check the result for each line. Right now, I need to select each line, press F9, move to the next line, and repeat these three steps for the next line. It would be easier if there is some key stroke combinations like c-? so that one key stoke combination does the above three actions all together. Thanks Jeff On Feb 17, 4:40=A0pm, "Jeff Cen" <h...@andrew.cmu.edu...

Custom Tangent Lines, Custom Line Thickness
I've tried creating a custom line type to show a thin tangent line in drawings that has a gap at either end. How can I specify that the line should be continuous between the other lines. Using Solid Edge, I think this was the standard way it displayed tangent lines. SWx seems only to be able to chain a pattern. Is there a way of displaying a single line between two tangents, instead of displaying the tangents, maybe like a virtual edge? Is there a way of creating a custom line thickness, other than thin, normal, thick, and thick+? Parts that have many tangent edges get displayed with ...

Web resources about - tangent line from curve graph - comp.soft-sys.matlab

Tangent space - Wikipedia, the free encyclopedia
A pictorial representation of the tangent space of a single point, x , on a sphere . A vector in this tangent space can represent a possible ...

The Dark Tangent (@thedarktangent) on Twitter

Tangent - Add Geometric Shape, Pattern, Texture, and Frame Overlays and Effects to Your Photos on the ...
Get Tangent - Add Geometric Shape, Pattern, Texture, and Frame Overlays and Effects to Your Photos on the App Store. See screenshots and ratings, ...

With Photo-Editing App Fragment, The Creators Of Tangent Have Done It Again
... overlays to photos, which consist of shapes that are made up of the photo's fragments With Photo-Editing App Fragment, The Creators Of Tangent ...

Price Drop: Tangent
Tangent 1.2 Device: iOS Universal Category: Photography Price: Free, Version: 1.2 ( iTunes ) Description: Previous Editor's Choice New & Noteworthy ...

Every Tech Tangent President Obama Went Down During Last Night’s SOTU
(GIF: Twitter/Bizweekgraphics) Despite Anonymous' worst intentions , the State of the Union went off without a hitch last nightsave for reducing ...

The business of play: Wild Tangent grows its Pioneer Square studio
Some of the world’s largest game-makers are in this region. Many have grown up from the two console-makers that are based here – Microsoft’s ...

How Christians Can Avoid Tangents and Fanaticism
Some movie stars are fanatics. So are some politicians. Even some famous athletes are fanatical. So it shouldn't surprise us that some Christians ...

Meet Dark Tangent, the hacker behind Black Hat and DEF CON - CNN.com
The word "hacker" evokes all kinds of scary images.