Least squares

Assignment Help MATLAB Programming
Reference no: EM131702

If A is an m by n rectangular matrix with m >= n and if c is a vector with n components then A c = y can not usually be solved exactly.  Matlab can solve these equations approximately with the command c = A \ y.   The solution c is called the "least squares" solution for reasons that we will describe later in the course.  To illustrate an application involving this use of a rectangular matrix suppose that we wish to fit the three points (0,3),  (2,5), and (4,6) with a straight line.  Then as we described earlier we can let the line be described by c1' + c2 x, let c = [ c1 ; c2] (using Matlab notation for vectors), let y = the vector of y values.and let A be a Vandermonde matrix with components aij= xIj-1 .  To fit the line to the data we need to try to solve the equation  A c = y..  In this example one can create A with the Matlab command A = [ 1 0;1 2;1 4] and y with y = [3 ; 5; 6].  Then c = A \ y gives c = [3.1667; .75].  The commands

 x=[0; 2; 4]                 % x isthe vector of x coordinates

 plot(x,y,'o',x,A*c)     % note that A*c generates points on the best fit line

 xlabel('x')

 ylabel('y')

 title('given points (o) and least squares fit (line)')

will plot the given points and the line 3.1667  + .75 x.  See the figure below.

For homework consider the points (0,0), (1,2), (2,3), (3,9), ( 4,17), (5,24), (6,37). (1) Use Matlab to find the least squares best fit with a line.  Turn in A, y and c and a plot like the one above.  Also (2) use Matlab to find the least square best fit with a quadratic.  Turn in the same information.

553_least_square.jpg

Reference no: EM131702

Questions Cloud

Filtering and summarizing data : Filtering and Summarizing Data
Identify and describe the organizational authentication : Identify and describe the organizational authentication technology and network security issues
Health economics assignment : Health economic theory and practice
Evaluate the correlation coefficient : Evaluate the correlation coefficient.
Least squares : For homework consider the points (0,0), (1,2), (2,3), (3,9), ( 4,17), (5,24), (6,37). (1) Use Matlab to find the least squares best fit with a line.  Turn in A, y and c and a plot like the one above.  Also (2) use Matlab to find the least square best..
Calculate the correlation coefficient : Calculate the correlation coefficient
The problem of operating a warehouse : Consider the problem of operating a warehouse, by buying and selling the stock of a certain commodity, in order to maximize profit over four periods.
Create a multi-threaded competition : Create a multi-threaded competition
Evaluate particle diameter at different gas velocities : Evaluate particle diameter at different terminal gas velocities

Reviews

Write a Review

MATLAB Programming Questions & Answers

  Write the commands that will create the matrix

Write the commands that will create the matrix.

  Calculate the distance between cities

Calculate the distance between cities

  Symmetry in the rod

matlab programming

  Calculate and plot the error in the numerical derivative

Write a program to calculate and plot the error in the numerical estimate of the derivative.

  Write project report and provide cross-synthesis

Write project report and provide Cross-synthesis.

  Design and fir filter in matlab

What does the pole-zero diagram tells you about the filter

  Find the integral of a function at an arbitrary location

Write a Matlab function to perform numerical integration of a set of evenly spaced data points using the trapezoidal rule

  Make a program that will graph the parabolas

Make a program that will graph the parabolas each parabola a different color and put all the parabolas in the same figure or graph

  Mat lab programming problem

In case the problem in the code I want you to modify it give the correct temperature.

  Construct the shear force and bending moment diagrams

Write the algorithm and draw the flowchart for each problem

  Lagrange interpolating polynomial of degree

Lagrange interpolating polynomial of degree

  Fingerprint watermarking techniques

Need to investigate the best method to embed watermark image into fingerprint image.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd