# Re: linear fit

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed, 4 Oct 2006 19:15:11 -0600 (MDT)

>
> I want to plot a curve with its linear fit. Which function can be work?
>
> ****************************************

The functions "regline" or "regCoef"

Some usage examples:

------------------------------------------------------------

if the "x" axis is time[*] and "y" is a time series of T[*]

r = regline(time,T)

; y = mx+b
; m is the slope: r returned from regline
; b is the y intercept: r_at_yave attribute of r returned from regline

data = new ( (/2,dimsizes(T)/), typeof(T))
data(0,:) = T
data(1,:) = r*(T-r_at_xave) + r_at_yave

res = True
res@ ..... = .....
plot = gsn_csm_xy (wks, time, data, res)

Good luck
D
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Oct 04 2006 - 19:15:11 MDT

This archive was generated by hypermail 2.2.0 : Thu Oct 05 2006 - 16:02:22 MDT