Least squares fit/line fit for 3D data
43 次查看(过去 30 天)
显示 更早的评论
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
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!