As an engineer, you are asked to calculate the approximate surface area of a lake in your local community. To do that, you decide to use a GPS to measure the x and y coordinates at various points around the lake. You pick a starting point and calibrate your GPS position at that point to be (0,0). You begin to walk around the lake collecting the following data below and eventually return to your starting position.
Upon looking at the plot above, you realise that the best way to calculate the area of the lake is to split the data into two sets, fitting a polynomial to each data set and the integrating the polynomials to approximate the area of the lake. I.e. Calculate the area above the red line and add it to the area below the red line. However, to do this, you need to determine where the polynomial crosses the red line (i.e. the root of the function) so that the limits of the integral are known.
Write an m-file which does the following:
Creates 2 sets of data for x [0 14] and x [14 0] with their corresponding y values. Fit 4th order
polynomials to each set of data and output the equation for each fit using fprintf.
Use the polynomial fit form part A to calculate the root of the polynomial that crosses zero. You
may use the fzero function.
Apply the Simpson’s 1/3rd rule using 21 points on the polynomial above the red line.
Apply the Simpson’s 1/3rd rule using 21 points on the polynomial below the red line. You will need
to use your result from part B here.
Calculate the area of a single trapezoid found above the red line between the root crossing and
x=14. This represents the excess area that needs to be subtracted.
Calculate the approximate area of the lake.