tags:

views:

319

answers:

2

Dear All,

I hope somebody here can help me with my problem.

I have matrix equation below:

[M] = [A][R] + [B][L]

where: A and B = 2 by 2 matrices

M, R, L, and = 2 by 1 matrix.

To estimate one specific value of A and B, I have 9 different data of [M], [R], and [L]. Let's say that these 9 data is one-group, and I have hundreds of group-data.

And I need to find the value of A and B related to specific group-data.

So does somebody have or know something with matlab of how to get the values of [A] and[B] for each group by just simply give input of [M], [R], and [L] data into matlab?

best,

-Bree

A: 

You can't matricies of different sizes. This equation makes no sense to me.

UPDATE:

This updated equation makes sense.

It sounds like a least squares fitting problem. You're going to enter your data and get the best estimate you can for the coefficient matricies. I'd have to know more about the exact nature of the data, groupings, etc., but I'd recommend that you start reading about MATLAB's least squares fitting capabilities.

Least squares fitting starts by coming up with a model. Let's assume you have three independent variables (x, y, z) and one dependent variable (v):

alt text

You now have four coefficients you need to solve for. You'll have n sets of points, where n > 4, so you'll need to do a least squares fit.

If you substitute your points into the equation you'll end up with a matrix equation:

alt text

If you premultiply both sides by the transpose of alt text, you'll have a square matrix that you can invert and solve for the coefficients.

This formulation allows higher order polynomials as well.

duffymo
Why not? [Xm;Ym], [xr;yr], [xl;yl], and C are 2-by-1 matrices. A and B are 2-by-2 matrices.So,[Xm;Ym] = A x [xr;yr] + B x [xl;yl] + C is just normal matrix equation, right?
Bree
Hi duffymo,I just change the equation, hope you do not misunderstood with the equation. best
Bree
MUCH better! I'll update my answer accordingly.
duffymo
Thanks Duffymo,I am reading the capabilities of MATLAB's least square fitting right now, but still could not find the way that can handle equation with 4 independent variables (inputs) and 1 dependent variable (output) like my matrix-equation is.
Bree
@Bree, I'll have to look into it tonight when I get home.
duffymo
HI duffymo, I found the solution by simply used MRDIVIDE or MLDIVIDE function in matlab. But unfortunately, that way was not the answer for my real problem. I am trying to track the gaze using webcam via matlab. already succeeded with detecting the eye position, but still struggling in transforming the eye position into the gaze at display. anyway, thanks for the answer
Bree
+2  A: 

I something is wrong with the way you have set up your problem. No matter what values M, R, and L have your equation is going to have an infinite number of solutions.

Regardless of the values of M, R, and L, one solution is [A] = [0], [B] = [0], [C] = [M]. In fact if you set [C] = [M], then [A] and [B] can be any matrices for which [A][R] = [0] and [B][L] = [0], and there are an infinite number of those.

Post-Comments edit

OK, I read your comment below a bit more carefully. I think the original way you stated your question is a bit misleading. In your new formulations you have 9 instances of

Xm = a Xr + bYr + cXp + dYp

This is typically put in terms of a 9x4 matrix multiplying a four vector giving a 9 vector:

y = X b

Where y is a 9x1 vector containing your Xm, X is the 9x4 matrix containing your 9 rows of Xr, Yr, Xp, and Yp values, and b is the unknown we'd like to solve for.

If the all the equations are linearly independent the system is over-determined so you can't get an exact solution, only a best fit. To do a linear least squares fit in Matlab the command is:

b = X\y

b will be the 1x4 vector containing a, b, c, and d which is the least squares approximation to a solution. See this matlab reference.

Charles E. Grant
Hi Charles, Thanks for your answer, yups.. that makes sense (I should exclude the C though). In simple, the equation is a linear equation with 4 independent variables (inputs) and 1 dependent variable (output). the equation is:Xm = aXr + bYr + cXp + dYp where a,b,c,d are constants.To find those a,b,c,d. I have 9 different Xm values related to 9 different values of Xr, Yr, Xp, Yp.What I need to know is whether there's simple way to find a,b,c,d in matlab.
Bree
I think you still have too many free variables. If you limit A and B to multiples of the identity matrix your equation becomesM = a R + b L where a, and b are simply numbers. This is uniquely solvable as long as R and L are linearly independent. If R and L are not linearly independent then your equation isM = D Rwhere D ~ (A + B), and you are back to having an infinite number of solutions.
Charles E. Grant
I got the idea, and thanks for that. After trying several data, it came to the conclusion and it would not flexible to just simply calculate the coefficient (a,b,c,d) for my system. I am developing the gaze tracking system under matlab via webcam. Succeeded with the eye tracking, but dunno how to transform eye positions into the gaze. in my last equation, indexs m = monitor, r = right pupil, l = left pupil. I think least will not enough for the system, start to try clustering though. Once again, Thank for the answer
Bree

related questions