Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Obtaining the equation of lsline

920 views
Skip to first unread message

Madhu Shurpali

unread,
Dec 8, 2009, 4:53:03 AM12/8/09
to
hello,

I have a hysteresis curve and afer plotting it I can plot a least squares linear fit line by using lsline.

What I want to do is get the slope and intercept of that lilne. Can somebody suggest how to get it?

Thanks
Madhu

Jos (10584)

unread,
Dec 8, 2009, 5:32:02 AM12/8/09
to
"Madhu Shurpali" <madhu.s...@cvgrp.com> wrote in message <hfl7lv$sls$1...@fred.mathworks.com>...

see POLYFIT

x = 1:10 ;
y = 2 * x + 10 + randn(size(x)) ;
plot(x,y,'bo') ;
h = lsline ;
% use the raw data to get the intercept and slope
p = polyfit(x,y,1)
% or using the line drawn by LSLINE
p2 = polyfit(get(h,'xdata'),get(h,'ydata'),1)

Take care when using lsline on plots with multiple line objects ...

hth
Jos

Madhu Shurpali

unread,
Dec 8, 2009, 5:40:21 AM12/8/09
to
Thanks a lot for the help.
0 new messages