Best Fit Line Drawing
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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
0 Kommentare
Antworten (3)
Daniel Shub
am 11 Jan. 2013
Bearbeitet: Daniel Shub
am 11 Jan. 2013
For a straight line you can use lsline
plot(randn(10, 1), '*')
lsline
1 Kommentar
Azzi Abdelmalek
am 11 Jan. 2013
Bearbeitet: Azzi Abdelmalek
am 11 Jan. 2013
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
0 Kommentare
José-Luis
am 11 Jan. 2013
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-.');
0 Kommentare
Siehe auch
Kategorien
Mehr zu Multirate Signal Processing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!