tangent line from curve graph

  • Permalink
  • submit to reddit
  • Email
  • Follow


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.

Thanks in advance.
0
Reply mulan_nuri (3) 2/22/2009 12:19:01 AM

See related articles to this posting


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
Reply spamanon (2438) 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.

Sorry,if i already misunderstood your opinion.
0
Reply mulan_nuri (3) 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.
> 
> 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.
0
Reply spamanon (2438) 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.
> 
> Thanks in advance.

  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
Reply ellieandrogerxyzzy (4806) 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
Reply mulan_nuri (3) 2/22/2009 9:46:02 AM
comp.soft-sys.matlab 203785 articles. 537 followers. Post

5 Replies
171 Views

Similar Articles

[PageSpeed] 24


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

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

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

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

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

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

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

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 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? :) ...

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

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

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

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

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

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

When displaying line graphs with line markers and error bars, the legend shows error bar icons instead of line marker icons.
For many years, I've complained to SPSS that when displaying line graphs wi= th line markers and error bars, the legend shows error bar icons instead of= line marker icons. This is very problematic. Often, it is appropriate to produce a black-and-w= hite line graph containing multiple lines with each line having an identica= l style. The only thing that distinguishes the lines are the markers, and y= et the legend fails to include this essential element. Institutional issues= prevent me from communicating directly with SPSS tech support, so I hope t= hat some kind soul will for...

How to add points like * to a plotyy graph or line graph?
I am kinda stuck here... below is my matlab code: figure hold on ax1 = gca; hl1 = line(x,y,'Color','b'); set(ax1,'XColor','b','YColor','b'); ax2 = axes('Position',get(ax1,'Position'),... 'XAxisLocation','top',... 'YAxisLocation','right',... 'Color','none',... 'XColor','k','YColor','k'); hl2 = line(x,z,'Color','k','Parent', ax...

Demo for 2D AA lines, curves filled curves ?
Is there any OpenGL demo that shows 2D AA lines, curves, and filled curves ? Thanks, Mik -- ...

Straight horisontal line trough single-line graph
Access 2003 I have a simple line graph with one line and I need an extra horizontal line in that graph. I want something similar to this, (without the vertical line): http://www.peltiertech.com/Excel/Charts/ComboCharts.html#AddLine except the value for the "height" of the horizontal line will change for each record. Information on how to manipulate graphs like this in Access 2003 seems sparse and I can`t figure out how to do it. Any ideas out there? Any help is appreciated. I did the "Export needed data to Excel and create and run macro from Access VBA" posted by...