comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Showing the least-squares line through a set of x,y points
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Showing the least-squares line through a set of x,y points [message #65314] Mon, 23 February 2009 09:55 Go to previous message
bobbylough is currently offline  bobbylough
Messages: 7
Registered: February 2009
Junior Member
On Feb 22, 4:34 am, David Fanning <n...@dfanning.com> wrote:
> bobbylough writes:
>> I was wondering if it could be possible to plot the least-squares line
>> for a set of points on a 2D plot for a set of x,y points. This would
>> involve reading the set of points via a textfile initially and then
>> including additional syntax that would compute the "best-fit" line
>> (this is correctly called the line of least-squares) through these
>> points. I'm well capable of doing this in Excel but have had
>> difficulty tracking the correct commands in IDL. Many thanks for any
>> help you can give me on this problem.
>
> I would do something like this:
>
> IDL> x = indgen(20)
> IDL> y = 3*x + 5 + RandomU(-3L, 20) * 10
> IDL> plot, x, y, psym=2, symsize=2
> IDL> result = linfit(x, y, YFIT=yfit)
> IDL> oplot, x, yfit, thick=2
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

Thanks David, worked a treat!!

Robert.
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: nCDF_Browser Updated to Support HDF Files
Next Topic: Band+Lat+Lon = georeferenced file?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 01:31:55 PDT 2025

Total time taken to generate the page: 0.55943 seconds