Path: news.mathworks.com!not-for-mail
From: "Ion " <xeradius@yahoo.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How I can find the slope of a tangent line and plot that tangent line in matlab
Date: Fri, 23 Jan 2009 18:00:21 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 42
Message-ID: <gld0jk$pfu$1@fred.mathworks.com>
References: <gla5or$f3p$1@fred.mathworks.com> <glajn1$9ro$1@fred.mathworks.com> <glcikq$80r$1@fred.mathworks.com> <glclgm$jtk$1@fred.mathworks.com>
Reply-To: "Ion " <xeradius@yahoo.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 1232733621 26110 172.30.248.35 (23 Jan 2009 18:00:21 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 23 Jan 2009 18:00:21 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1681987
Xref: news.mathworks.com comp.soft-sys.matlab:513478

"someone" <someone@somewhere.net> wrote in message <glclgm$jtk$1@fred.mathworks.com>...
> "Ion " <xeradius@yahoo.com> wrote in message <glcikq$80r$1@fred.mathworks.com>...
> > This is my function script.
> > function [slop]=tangentline(A,B,C,D,x,Location)
> > % A,B,C,D	: 		These are the coefficients of the polynomial function. 
> > % x	        :			This is the name of the independent internal 
> > % variable.  x must be defined before calling this &#8220;tangentline&#8221;function. So don&#8217;t use a number!. 
> > % Location	:	This variable tells you where the function must
> > % 					plot the tangentline. This location must be in the 
> > % 					range of the independent variable.
> > % 					For x=3, we type only "3" instead of "Location"
> > 
> > 
> > slop=3*A.*Location+2*B.*Location+C
> > 
> > y=x.^3+x.^2+x
> > plot(x,y)
> > hold on
> > 
> > 
> > b=(A.*Location.^3)+(B.*Location.^2)+(C.*Location)+D
> > y2=slop*(x-Location)+b
> > plot(x,y2,'r')
> > hold off
> > 
> > But the problem apers when i call for this function
> > For example
> > >> x=linspace(3,9);
> > >> tangentline(1,2,2,3,x,6)
> > My slope it will be calculated but my plot is not shoing the real tangent line of that function.
> > I wait for your answers.Thank you.
> 
> % I think you need to replace the line:
> slop=3*A.*Location+2*B.*Location+C
> % with:
> slop=3*A.*(Location^2)+2*B.*Location+C
> 
> % See if that works.

I tried and it acts in the same way.The problem is still unsolved.