f



how to find slope and intercept.

If i have a linear trend that starts at x and y axis values that are above
and right of the origin how can I:

a - interpolate back to find the intercept
b - find an interpolated value at a given point on the trend

I know that the straight line is y= Mx+C but can't see how to apply this.

thanks in anticipation
SS.


0
1/22/2004 10:20:51 PM
comp.soft-sys.matlab 211094 articles. 13 followers. lunamoonmoon (258) is leader. Post Follow

11 Replies
871 Views

Similar Articles

[PageSpeed] 17

"SS" <webmaster@srsteel.co.uk> wrote in
news:bupibs$d58$1@news.freedom2surf.net: 

> 
> If i have a linear trend that starts at x and y axis values that are
> above and right of the origin how can I:
> 
> a - interpolate back to find the intercept

You cannot interpolate to find the intercept.  You must extropolate

Scott
0
namdiesttocs (1203)
1/22/2004 10:33:04 PM
oops.
thats what I meant...

silly me.

SS


0
1/22/2004 10:40:58 PM
SS,

If the equation of your line is
y=Mx+C then the Y-intercept can be found by setting X=0 and solving
the equation for y. The X-intercept can be found by setting Y=0 and
solving the equation for X. The slope of the line, M, is:

M = (y2-y1)/(x2-x1) where (x1,y1) and (x2,y2) are points on the line.
Hint: the intercepts are points on the line.

hope that helps,

Scott
0
no18 (4537)
1/22/2004 10:44:06 PM
what I was really hoping for was a pointer to the help command.
I should probably have asked directly what the help command i needed was.

I found 'help interp'

but can't find what the help command is for extrapolation....

SS


0
1/22/2004 10:53:14 PM
When you view "help interp" it will show related functions at the
bottom of the help dialog box. Extrapolation should show up there.

hth,

Scott
0
no18 (4537)
1/22/2004 11:29:08 PM
what i see is:

>> help interp

 INTERP Resample data at a higher rate using lowpass interpolation.
    Y = INTERP(X,R) resamples the sequence in vector X at R times

<snip>

    See also DECIMATE, RESAMPLE, UPFIRDN.


0
1/22/2004 11:47:30 PM
On Thu, 22 Jan 2004 23:47:30 +0000, SS wrote:

> what i see is:
> 
>>> help interp
> 
>  INTERP Resample data at a higher rate using lowpass interpolation.
>     Y = INTERP(X,R) resamples the sequence in vector X at R times
> 
> <snip>
> 
>     See also DECIMATE, RESAMPLE, UPFIRDN.

Here's a Matlab function you will find useful.

help lookfor

Dan
0
dan4519 (925)
1/23/2004 12:00:28 AM
Ok - lookfor extrapolate yielded me:

>> lookfor extrapolate
extrapolate_values.m: %EXTRAPOLATE_VALUES
extrapolate_values_RBF.m: %EXTRAPOLATE_VALUES_RBF
extrapolate_values.m: %EXTRAPOLATE_VALUES
extrapolate_values_RBF.m: %EXTRAPOLATE_VALUES_RBF

but when i then do :
>> help extrapolate _values
I get
extrapolate.m not found.

Am i missing the point?

in the meantime - I've got...
======================================
x = [ 2  2.5  3  3.5  4]
y = [0.0073  0.0086  0.0099  0.0112  0.0125]
%m = (y2-y1)/(x2-x1)
m =  (0.0125 - 0.0073) / (5.4 - 2)
plot (x,y)
======================================

from my values above
0.0125 = 4m + c
0.0073 = 2m + c

subtracting gives

0.0052 = 2m
so m = 0.0026

substituting back in to solve for c gives c = 0.0021.

So I could now plug values in and find my desired previously unknown value.
but could I have done this with a simple command in matlab?

=====================================
Incidentally - I think that this is a good example of what seasoned hands
would class as newbies clogging up the NG.
For me the problem is - I'm trying to use Matlab to do occasional bits and
pieces. I struggle to find the time to gain a working knowledge of the prog'
I tend to find that the help system is less than useful at times.
I know I want to extrapolate some values but the commands I've used to try
to find the info within the system have yielded me nothing useful.
The command must be there but i've wasted time looking for it with no
benefit.

I'm pretty sure this is why some (not all) of us lesser users tend to jump
in and just ask the question...'how do I...?'

but still...thanks for the help so far..
I'm off to bed.

SS.




0
1/23/2004 12:19:16 AM
SS wrote:
> what I was really hoping for was a pointer to the help command.
> I should probably have asked directly what the help command i needed
> was.
>
> I found 'help interp'
>
> but can't find what the help command is for extrapolation....
>
> SS

Since you're trying to extrapolate a line back to the X and Y axes, you
actually don't need to use a command line INTERP or anything like that -- 
backslash will do all you need.   If you have X and Y data in column vectors
(which looking back in the thread, it sounds like you do) the following
gives you the coefficients of the best-fit line:

MB = [X ones(size(X))] \ Y;

% Each row of the corresponding linear system is x*MB(1) + MB(2) = y
% for corresponding elements of x and y.

The equation of the best fit line is y = MB(1)*x  + MB(2).  Now that you
have the equation of the line, finding the intercepts is a simple matter of
plug-and-chug.

-- 
Steve Lord
slord@mathworks.com


0
slord (13687)
1/23/2004 1:19:38 PM
SS,

Use polyfit(x,y,n) to find the least squares fit
to your data.

 >> x = [ 2  2.5  3  3.5  4]
x =
     2.0000    2.5000    3.0000    3.5000    4.0000
 >> y = [0.0073  0.0086  0.0099  0.0112  0.0125]
y =
     0.0073    0.0086    0.0099    0.0112    0.0125
 >> polyfit(x,y,1)
ans =
     0.0026    0.0021

The answer from polyfit means: y = .0026*x + .0021

If you want to know how it works, then look up
'Least Squares' in your linear algebra book.

Gordon Weast
xPC Target Development
The Mathworks

SS wrote:

> Ok - lookfor extrapolate yielded me:
> 
> 
>>>lookfor extrapolate
> 
> extrapolate_values.m: %EXTRAPOLATE_VALUES
> extrapolate_values_RBF.m: %EXTRAPOLATE_VALUES_RBF
> extrapolate_values.m: %EXTRAPOLATE_VALUES
> extrapolate_values_RBF.m: %EXTRAPOLATE_VALUES_RBF
> 
> but when i then do :
> 
>>>help extrapolate _values
> 
> I get
> extrapolate.m not found.
> 
> Am i missing the point?
> 
> in the meantime - I've got...
> ======================================
> x = [ 2  2.5  3  3.5  4]
> y = [0.0073  0.0086  0.0099  0.0112  0.0125]
> %m = (y2-y1)/(x2-x1)
> m =  (0.0125 - 0.0073) / (5.4 - 2)
> plot (x,y)
> ======================================
> 
> from my values above
> 0.0125 = 4m + c
> 0.0073 = 2m + c
> 
> subtracting gives
> 
> 0.0052 = 2m
> so m = 0.0026
> 
> substituting back in to solve for c gives c = 0.0021.
> 
> So I could now plug values in and find my desired previously unknown value.
> but could I have done this with a simple command in matlab?
> 
> =====================================
> Incidentally - I think that this is a good example of what seasoned hands
> would class as newbies clogging up the NG.
> For me the problem is - I'm trying to use Matlab to do occasional bits and
> pieces. I struggle to find the time to gain a working knowledge of the prog'
> I tend to find that the help system is less than useful at times.
> I know I want to extrapolate some values but the commands I've used to try
> to find the info within the system have yielded me nothing useful.
> The command must be there but i've wasted time looking for it with no
> benefit.
> 
> I'm pretty sure this is why some (not all) of us lesser users tend to jump
> in and just ask the question...'how do I...?'
> 
> but still...thanks for the help so far..
> I'm off to bed.
> 
> SS.
> 
> 
> 
> 

0
gweast (587)
1/23/2004 2:32:20 PM
cheers...

stand by what I said earlier...

always more than one way....
thanks all
:o)

SS


0
1/23/2004 6:57:25 PM
Reply: