Plane of best fit (without using the sftool)

조회 수: 4 (최근 30일)
kanai
kanai 2013년 7월 31일
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

답변 (1개)

Tom Lane
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
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.
kanai
kanai 2013년 8월 15일
Apologies but that has not worked for me
b=x\y gives me a number (-17.3271)
Can you give me any further help? Also once I have an equation of a plane (for the moment I will use the plane calculated by the sftool), say it is x+y+z=0, how to I plot this?
Many thanks

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile 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!

Translated by