Least squares fit/line fit for 3D data

47 ビュー (過去 30 日間)
Wes Anderson
Wes Anderson 2019 年 12 月 4 日
編集済み: Matt J 2019 年 12 月 4 日
I have 3D data that I'd like to get a least squares fit from. Once I have this fit with an equation, I'd like to transform new data with it...so I need the code and to understand where to plug the new data into whatever equation comes from it. Can anyone help? Much appreciated.
Thanks

回答 (1 件)

Star Strider
Star Strider 2019 年 12 月 4 日
For a linear regression, this is straightforward:
B = [x(:) y(:) ones(size(x(:)))] \ z(:); % Linear Parameters
z_fit = [x(:) y(:) ones(size(x(:)))] * B; % Fitted ‘z’
For a nonlinear regression, we would need sto see your model.
  1 件のコメント
Matt J
Matt J 2019 年 12 月 4 日
編集済み: Matt J 2019 年 12 月 4 日
This looks like a plane fit to me. A 3D line fit would result in 2 algebraic equations.
Also, the fit looks like it assumes no errors in x and y.

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

カテゴリ

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