Using SVD for Least Squares Problems in MATLAB

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
4 replies · 2K views
squenshl
Messages
468
Reaction score
4

Homework Statement


The link http://www.york.ac.uk/depts/maths/data/ts/welcome.htm gives the average monthly temperature T in Fahrenheits for Dubuque, Iowa from 1964 to 1975. Let T = a0 + sum from i = 1 to k of ai cos(2*pi*i*m/12) + sum from i = 1 to k of bi sin(2*pi*i*m/12) where m is the number of months from January, 1964.
Use the SVD and MATLAB to find suitable values of a and b for k = 2 and k = 4. As part of your answer include a plot which displays the data abd T for k = 2 and k = 4.

Homework Equations


SVD equations

The Attempt at a Solution


How do I even start to answer the question. Do I put the 144 data values in matrix form and use the svd command in matlab.
 
Physics news on Phys.org


Have you studied how to use the SVD in getting the best solution to an overdetermined system of equations?

The way I look at this problem, you have a linear equation for each month of data. For month j , the right hand of the equation is the temperature [tex]T_j[/tex]. For the case k = 2, the unknowns are [tex]a_0, a_1, a_2, b_1, b_2[/tex]

For example, for the month 5, the equation is

[tex]a_0 + a_1 \cos(2\pi(1)(5/12)) + a_2 \cos(2\pi(2)(5/12)) + b_1 sin(2\pi(1)(5/12) + b_2 sin(2\pi(2)(5/12) = T_5[/tex]

(The coefficients of the unknowns are all numerical values than you can compute.)

The matrix is the big matrix that defines this system of linear equations.

There are routines in MATLAB to read data from files and construct matrix entries from computations. I don't think you are meant to type-in each entry of the matrix by hand.
 


I just copied the data from the website and then applied the svd command in MATLAB to get 3 matrices U, S, V.
 
Last edited: