Help with basic fitting
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
aurc89
am 23 Feb. 2014
Kommentiert: Image Analyst
am 25 Sep. 2018
Hello,I would like to fit a curve with a line and retrieve slope and intercept of this linear fit. Let x and y be the vectors which define the curve, which is already similar to a line; I plot x vs y, then from the plot window I select Tools --> Basic fitting --> Linear fit, then I press 'Show equation' so that from the expression y=mx + q I retrieve both the slope m and the intercept q. The problem is that I want to obtain immediatly m and q from the Matlab code, without doing it manually as discussed above. How can I do this ? Thanks
0 Kommentare
Akzeptierte Antwort
Mischa Kim
am 23 Feb. 2014
Bearbeitet: Mischa Kim
am 23 Feb. 2014
Try
[p,S] = polyfit(x,y,1)
The two elements of p are the coefficients m and q you are looking for.
2 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Linear and Nonlinear Regression 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!