フィルターのクリア

fit a curve with smallest distance in y AND x direction to data points

6 ビュー (過去 30 日間)
F S
F S 2017 年 11 月 22 日
コメント済み: Image Analyst 2017 年 11 月 27 日
I have two sets of measurements x and y that seem to be correlated when plotting them against each other (below a small subsample of my data). I would like to fit a curve (linear, exponential, polynomial ..) through my data, such that it minimizes the distance of my points to the line (in an absolute or mean square way), but not only minimizing the distance on the y axis, but the closest distance in the x,y plane (euclidean distance). Is there a function/way to do that? As I understand it, most curve fitting functions in MATLAB fit the according to the rmse in y-direction only.
x =[1.3049 1.4137 0.2165 0.6538 0.6135 1.0655]
y =[4.0280 4.0865 50.1873 11.8024 7.9184 5.5866]
  2 件のコメント
Roger Stafford
Roger Stafford 2017 年 11 月 23 日
If you use a fifth order polynomial, here's about as close as you can get:
X = [1.3049 1.4137 0.2165 0.6538 0.6135 1.0655];
Y = [4.0280 4.0865 50.1873 11.8024 7.9184 5.5866];
Y2 = 469.165558828655 - 3459.00108010757*X + 9145.4534625995*X.^2 ...
- 11008.7869446613*X.^3 + 6175.46754074994*X.^4 - 1313.19614251125*X.^5;
x = linspace(.2,1.5);
y = 469.165558828655 - 3459.00108010757*x + 9145.4534625995*x.^2 ...
- 11008.7869446613*x.^3 + 6175.46754074994*x.^4 - 1313.19614251125*x.^5;
[Y;Y2]
plot(x,y,'y-',X,Y2,'yo',X,Y,'r*')
F S
F S 2017 年 11 月 27 日
Thank you! A fifth order polynomial is likely to hugely over fit the data though. And - more importantly - the way you did it if I'm not mistaken, you were minimizing the differences only in y-direction not in x AND y direction as I would like to (since I have errors on both measurements). Which function were you using for creating the result? Polyfit?

サインインしてコメントする。

採用された回答

Jeff Miller
Jeff Miller 2017 年 11 月 22 日
編集済み: Image Analyst 2017 年 11 月 27 日
It sounds like you want "orthogonal linear regression".
  2 件のコメント
F S
F S 2017 年 11 月 22 日
Thank you for the link! That's what I want, I think, just not only linear. Do you know a function that fits also more complex functions, e.g. an exponential orthogonally?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by