Best Fit Line Drawing

Dear All;
I have many points and i need to draw the best fit line between these points , how can i do it ?
Best Regards

답변 (3개)

Daniel Shub
Daniel Shub 2013년 1월 11일
편집: Daniel Shub 2013년 1월 11일

1 개 추천

For a straight line you can use lsline
plot(randn(10, 1), '*')
lsline

댓글 수: 1

Sean de Wolski
Sean de Wolski 2013년 1월 11일
That's awesome, learn something new every day!

댓글을 달려면 로그인하십시오.

Azzi Abdelmalek
Azzi Abdelmalek 2013년 1월 11일
편집: Azzi Abdelmalek 2013년 1월 11일

0 개 추천

Use interp1 function. You can also use a curve fitting toolbox
% Example
x=0:0.5:2
y=x.^2+2*x+rand(1,numel(x))
plot(x,y,'or')
xi=0:0.1:2;
yi=interp1(x,y,xi,'spline')
hold on
plot(xi,yi,'g')
hold off
José-Luis
José-Luis 2013년 1월 11일

0 개 추천

Without a toolbox:
x = 1:10;
y = x + randn(1,10);
plot(x,y,'b*')
P = polyfit(x,y,1);
yfit = P(1)*x+P(2);
hold on;
plot(x,yfit,'r-.');

카테고리

도움말 센터File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

태그

질문:

2013년 1월 11일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by