Regression/linear equation solving

I have a set of over defined equations that do not fit perfectly. The problem resembles this simpler problem in nature:
x1 = 0.8 + x2,
x1 = 1.2 + x2
x2 = 1.5 + x3
x3 = -3 + x1
x4 = -1.5 + x2
x4 = -1.7 +x2
I'm trying to solve for the x's, and they have values which are relative to one another, so i can assume for example that one of the x's is 0.
Because this is over defined, I would need to do a regression of some sort.
I'm feeling a bit foggy today, but I'm sure there's got to be a way to do this in MATLAB. Can anyone provide me with some sample code?

 채택된 답변

Tom Lane
Tom Lane 2012년 3월 5일

1 개 추천

Bring all the x's over to the left of the equal sign. Then a matrix representation of those equations is this:
1 -1 0 0
1 -1 0 0
0 1 -1 0
-1 0 1 0
0 -1 0 1
0 -1 0 1
Let this be A, and define a vector b that is is the vector of constant terms, and your least squares solution is A\b. MATLAB will automatically set one of the x values to zero for you.

댓글 수: 1

Matt
Matt 2012년 3월 5일
Thanks, this is exactly what I was looking for

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Spline Postprocessing에 대해 자세히 알아보기

태그

질문:

2012년 3월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by