Sunday, 15 September 2013

math - How do I use the least squares approximation in MATLAB? -


For homework work in linear algebra, I have solved the following equation using MATLAB's \ operator (

which is the recommended way to do it):

 A = [0.2 0.25; 0.4 0.5; 0.4 0.25]; Y = [0.9 1.7 1.2] '; X = a \ y 

which generates the following answer:

 x = 1.7000 2.0800 

For the next part of the assignment, let me solve it less Using the same approximation of squares, the same equation (and then compare it to the former value to see how precise the exact estimate is).

How do I get a way to do this in MATLAB?

Earlier work: I got the function lsqlin , which is capable of solving the above type of equation, but I do not understand which logic It will neither provide nor in what order.

mldivide , (" \ ") actually Does too According to:

If a m-by-n matrix is ​​a matrix with a column vector or several columns with an ML components with m ~ = n and B, then X = A \ B is the solution of the least squares that understands under the equations- or a highly-defined system AX = B. In other words, the X standard (A * X-B) is minimized, the length of the vector AX-B is determined by the QR decomposition with the A-K column pivot (see algorithm for details). In the calculated solution, the maximum K ngezero element near the X is per column. If a & lt; N, this is usually not the same solution as x = pinw (a) * b, which gives solution of at least intersections.

So in fact, what you did in the first assignment was to solve the equation using LSE.


No comments:

Post a Comment