Info
This question is closed. Reopen it to edit or answer.
Ordinary Least Squares Problem
1 view (last 30 days)
Show older comments
Hey guys, so I'm new to MATLAB and I got hung up on a particulat part of this problem part(c), if anyone has advice on any of the parts in this problem, that would be much appreaciated.
a. Create a row vector of 100 linearly spaced elements ranging from -10 to 10 and call it “x”.
b. Create a vector called y_original = m*x+b. (where: m = 2, b = -5)
c. Add white noise with an snr (signal-to-noise ratio) of 20 to the values of “y_original” and label this new vector “y_noise” (make sure y_original is not changed)
d. At this point, you now have realistic ‘x’ data and ‘y’ data. With this in mind, how could you re-arrange this data into a format such that you could use linear algebra to solve for the coefficients of the linear equation (m*x+b = y).
e. Set c = A\y. Make sure this is stored as a column vector.
f. What is the physical significance of these numbers?
g. Create a new vector called ‘y_predicted’ = A*c
h. Plot (x vs. y_noise) and (x vs. y_predicted).
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!