Plane of best fit (without using the sftool)
6 次查看(过去 30 天)
显示 更早的评论
I would like to to know the equation of a plane of best fit using a set of 20 xyz coordinates. I can do it using the SF tool but I would like to know the code to run for my data to get it in the command bar and without using the cumbersome SFtool
Once I have the equation I would like to find the point on the plane where a line crosses it. This line would be in a parametric format.
Many thanks kg
0 个评论
回答(1 个)
Tom Lane
2013-8-1
If you set up a matrix X with three columns containing your x values, your y values, and a column of twenty ones, and set up a Y column vector containing your z values, then
b = X\y
will return the least-squares coefficient estimates. This is the least squares solution in the sense of minimizing the errors in the z direction.
3 个评论
Tom Lane
2013-8-3
If you have x,y,z as column vectors of the same length, then
b = [ones(size(x)),x,y]\z
will estimate three coefficients for predicting z: the intercept, the multiplier of x, and the multiplier of y.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!