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?

 采纳的回答

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.

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Spline Postprocessing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by