#### 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 208639 articles. 8 followers. lunamoonmoon (258) is leader.

11 Replies
629 Views

Similar Articles

[PageSpeed] 7
```"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 (1202)
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>

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

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

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 (13691)
1/23/2004 1:19:38 PM
```SS,

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

>> 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
>
> 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
Similar artilces about - how to find slope and intercept.:

Find and Grep together
Hi All, I am sorry if this is not the right group for this question. I am using find and grep together to find a string in a file from the top level directories. find . -name "*.c" -exec grep "string" {} \; -print | more. | \/ top level directorie I am sure that the string I am searching is in the lower directories where I am searching but this command is unable to find the string which I am looking. Can anyone please help me. My version control tool is clear case and my config spec also supports all the files....

How to find out the current version of the MySQL installation ?
How to find out (from the command line under Linux) the current version of the MySQL installation ? Or is there a config file which contains the version number ? Werner Werner Sammer <wersam@yahoo.de> wrote: > How to find out (from the command line under Linux) > the current version of the MySQL installation ? > Or is there a config file which contains the version number ? > Werner Command line: mysql --version Regards, Johan -- _____________________________________ Ing. Johan van Oostrum chaos geordend - www.chaosgeordend.nl _____________________________________ >...

finding max
Hello all I have a matrix a = 1 2 3 4 5 6 7 8 9 10 11 12 now I call max(a) ans = 9 10 11 12 to find the max, I have to call max(max(a)) Is there any way I can get the max of a matrix in one command? Thanks sore wrote: > > Hello all > > I have a matrix > > a = > > 1 2 3 4 > 5 6 7 8 > 9 10 11 12 > > now I call > > max(a) > > ans = > > 9 10 11 12 > > to find the max, I have to call max(max(a)) > > Is there any way I can get the max of a matrix > in one command? >...

Narrowed down bottlneck to disk, how can I find out which FS is being hammered? 100% utilization
In my process of drilling down to get to the bottom of our performance issues, I am seeing huge I/O wait on a particular disk. What tools are available to dig deeper, find out which file system is hammering the disk and/or which processes are hogging the CPUS? We are talking 100% utilization here: mpstat output: CPU minf mjf xcal intr ithr csw icsw migr smtx srw syscl usr sys wt idl 0 199 0 259 12 2 176 9 22 30 0 1882 11 6 83 0 1 205 0 259 204 194 176 8 23 34 0 1801 11 5 84 0 2 203 0 289 34 23 176 7 23 31 ...

Find it all
Find it all http://asb-comm-logicx.net/ ...

Complicated Find Expression
Hi, I am having problems with my find expression. Basically I want to find to find all files that are _not_ in a test directory and then execute a grep statement on them. The result of that grep statement is further refined by another grep. Finally I would like to echo the result. My grep expression on works fine by itself. The problem is with the find integration. Here is my expression, followed by the output. Thanks for any suggestions/pointers, Mike find ./ -path '*test*' -prune -o -print -exec "grep -PRi 'out.print.*?[^/][^/].*?the' {} | grep -Pi 'out...

[ace-users] Can't find ACEd.dll
This is a multi-part message in MIME format. ------_=_NextPart_001_01C7A8F9.1452B078 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi=20 =20 ACE VERSION: 5.5.8 =20 HOST MACHINE and OPERATING SYSTEM: Win XP=20 If on Windows based OS's, which version of WINSOCK do you use?: don't know =20 TARGET MACHINE and OPERATING SYSTEM, if different from HOST: COMPILER NAME AND VERSION (AND PATCHLEVEL): =20 THE \$ACE_ROOT/ace/config.h FILE [if you use a link to a platform- specific f...

ow-find without sun 'find' key
I've just moved over to a windows platform from solaris and have installed the windows version of xemacs 21.4. I'm having severe withdrawal symptoms from the loss of the sun 'find' key. So to correct this I would like to bind the M-s key combo to the ow-find function and M-S-s to the ow-find-backward function. I have 2 problems trying to achieve this. 1. I have sucessfully bound the M-s keys to the 'ow-find function using the following code in the init.el file. (define-key global-map [(meta ?s)] 'ow-find) However when I execute the function it returns the follo...

find breakpoint programmatically
Hi All, &nbsp; I accidentally posted this question in the special interest forum by mistake so sorry for the duplicate post but i thought it might never get read over there. <a href="http://forums.ni.com/ni/board/message?board.id=BreakPoint&amp;message.id=4162" target="_blank">http://forums.ni.com/ni/board/message?board.id=BreakPoint&amp;message.id=4162</a> &nbsp; Hi all, &nbsp; I was wondering if there is a way to search the vi hierachy for breakpoints programmatically?&nbsp; Why you may ask? &nbsp; I have a piece of code that take...

Find File Attributes
Hello, As a part of my application,I need to compare files generated everyday.I need not need to compare the file contents.I just need to compare the file size,the line count.The files are named in the format,Hyyyymmdd,H denoting History. At present,I use the Dir function to search for the physical existence of the file and I use the debug.print for functions such as filelen(path),GetAttr() etc. My question is how would I put this as a module so that I can use a date function to compare files generated today with that of yesterday (mondays files to be compared against fridays). Also is it pos...

I need to find the rows that exist in one table but not in the other with condition
I need to find the rows that exist in one table but not in the other with this condition: (prod_name exist in table1 and not in table2.prod_name ) AND (prod_name exist in table1 and not in table2.'S'+prod_name ) explanation: i want to know if the product not exit and if the combination of the charachter "S" with the product Name also not exist at the other table B.R yuvi SELECT prod_name FROM table1 as A WHERE NOT EXISTS (select * from table2 as B where A.prod_name = B.prod_name) AND NOT EXISTS (select * from table2 as C where A....

Re: Find unique records and recode
data one; input old \$; cards; 5269-7c 5269-8c 5269-8c 5269-3z 5222-7z 5222-7z 5222-7z ; data two; set one; by old notsorted; new + first.old; run; On Mon, 5 Sep 2005 07:24:43 -0700, tortoise <cychen9@GMAIL.COM> wrote: >Hi, >I have one character variable (old). >There are many combinations of "old" variable. >How could I find unique and recode those data to "new"????? > > old new >5269-7c 1 >5269-8c 2 >5269-8c 2 >5269-3z 3 >5222-7z 4 >5222-7z 4 >5222-7z ...

pro/piping tutorials
Hello, does anyone know where I could find tutorials about pro/E module: pro/ piping? I would really appreciate any info on this. Thanks a lot! This is a multi-part message in MIME format. ------=_NextPart_000_0033_01C79EE3.B10443C0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable <dugave_11@yahoo.com> wrote in message = news:1180099763.016860.34260@o5g2000hsb.googlegroups.com... Hello, does anyone know where I could find tutorials about pro/E module: pro/ piping? I would really appreciate any info on ...

How to find out memory leak?
Hi, all! I'm having memory leak problem with my program, but can't find where's the leak. I have a program written in pure-Ruby. It implemented a Chinese word segment algorithm. I call `segment(text)' to get the result. But each time I call `segment', the memory usage of my program (Ruby) increased several handred K- bytes -- the number of bytes of increment is roughly equal during each call. I can see from outside (using `ps' or `top') that the memory is leaking. But I can't find where the leaking goes. I tried to use ObjectSpace.each_object to find out what ...

Help finding AIO w/Fax
I looking for an All In One with FAX (flatbed scanner) for less than \$200. I have only been able to fine these two: Canon MP390 and HP Officejet 5510. I do not see any that are Epson, Dell, Ricoh or Samsung. I have ruled out Visioneer and Lexmark because of bad reviews. Does anyone know of any other they recommend. Thanks in advance for your help, Bill ...

help
I received an Excel data file that contains a "+/-" symbol (html code \&plu= smn; &plusmn;), that can be copied and displayed in Word, Notepad, "Kompoze= r" html editor, unix vi, pico editors, and load to/retrieve from MySQL oper= ated on linux. But when I need to manipulate the data in perl, I am lost a= s how to recognize the symbol with RE. Could anyone help? Thanks in advance! joe On 2012-12-15 07:19, Joe wrote: > I received an Excel data file that contains a "+/-" symbol (html code \&plusmn; &plusmn;), that can be copied and...

find.find
import fnmatch, os def find(pattern, startdir=os.curdir): matches = [] os.path.walk(startdir, findvisitor, (matches, pattern)) matches.sort() return matches def findvisitor((matches, pattern), thisdir, nameshere): # for name in nameshere: if fnmatch.fnmatch(name, pattern): fullpath = os.path.join(thisdir, name) matches.append(fullpath) can someone explain why (matches, pattern) is doing in this two funct? thanks In <eo15uq\$hna\$1@ss408.t-com.hr>, Gigs_ wrote: > import fnmatch, os > > def find(pattern, startdir=os...

find opened classes
Is there any way I can find all the classes that have been re-opened in a project? On 8/21/07, nraychaudhuri@gmail.com <nraychaudhuri@gmail.com> wrote: > Is there any way I can find all the classes that have been re-opened > in a project? > > > No fool proof way. Are there particular changes to a class you are looking to track? For instance you can override method_added to see if anyone adds any additional methods. nraychaudhuri@gmail.com wrote: > Is there any way I can find all the classes that have been re-opened > in a project? > If you don't mind ha...

Find similar objetcs
Hi, I need to identify similar objects in my image. All objects are circles (size of the circle is not know). And some are overlapping and some not. I need to find how to find out which are overlapping. How do I approach this problem ? I have implemented Connected component algorithm to find all the connected components. What do I do after this? I need urgent help in this. I can't use any of the image processing functions like bwarea and bwboundaries. Is there any other way. any help is appreciated. Harry. ...

Is there a way to find objects ?
Hello, do you know how to spot non used objects (report, form, query....) in an access 2000 database 1/ in an "ordinary" case 2/ in case access basic is used and links are made only with access basic. ( i think it is necessary to browse the code ..?) ...