Question

Matlab code:Task 5 As an engineer you are asked to calculate the approximate surface area of a lake in your local community. In order toUpon 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

Task 5 As an engineer you are asked to calculate the approximate surface area of a lake in your local community. In order 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. 0 4 5 0 8 8.5 7.1 4.9 1.72.63.8-6.15.95.2-4.1 0 8 10 12 141210 8 4 outline of lake 10 2 10 12 14 x-values
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. L.e. Calculate the area above the red line and add it to the area below the red line. However, in order 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/3"d 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. a) b) c) d) e) f)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

x1=[0 2 4 6 8 10 12 14]

y1=[0 3 5 8 8.5 7.1 4.9 1.7]

x2=[14 12 10 8 6 4 2 0]

y2=[1.7 -2.6 -3.8 -6.1 -5.9 -5.2 -4.1 0]

P1=polyfit(x1,y1,4);

fprintf('1st data set equation is = (%d)x^4+(%d)x^3+(%d)x^2+(%d)x+(%d)\n',P1(1),P1(2),P1(3),P1(4),P1(5))

P2=polyfit(x2,y2,4);

fprintf('2nd data set equation is =(%d)x^4+(%d)x^3+(%d)x^2+(%d)x+(%d)',P2(1),P2(2),P2(3),P2(4),P2(5))

fun1=@(x1) (P1(1)*x1^4+P1(2)*x1^3+P1(3)*x1^2+P1(4)*x1+P1(5))

Function_1_Zero_at=fzero(fun1,0)

fun2=@(x2) (P2(1)*x2^4+P2(2)*x2^3+P2(3)*x2^2+P2(4)*x2+P2(5))

Function_2_Zero_at=fzero(fun2,0)

plot(x1,y1,x2,y2)

xlabel('x')

ylabel('y')

OUTPUT------------

x1 =

    0    2    4    6    8   10   12   14

y1 =

   0.00000   3.00000   5.00000   8.00000   8.50000   7.10000   4.90000   1.70000

x2 =

   14   12   10    8    6    4    2    0

y2 =

   1.70000  -2.60000  -3.80000  -6.10000  -5.90000  -5.20000  -4.10000   0.00000

1st data set equation is = (0.00126657)x^4+(-0.0398201)x^3+(0.251752)x^2+(0.920319)x+(0.0840909)
2nd data set equation is =(0.00106534)x^4+(-0.0313447)x^3+(0.427746)x^2+(-2.64708)x+(-0.0515152)fun1 =

@(x1) (P1 (1) * x1 ^ 4 + P1 (2) * x1 ^ 3 + P1 (3) * x1 ^ 2 + P1 (4) * x1 + P1 (5))

Function_1_Zero_at = -0.093815
fun2 =

@(x2) (P2 (1) * x2 ^ 4 + P2 (2) * x2 ^ 3 + P2 (3) * x2 ^ 2 + P2 (4) * x2 + P2 (5))

Function_2_Zero_at = -0.01940010 -10 10 12 14
Add a comment
Know the answer?
Add Answer to:
Matlab code: Task 5 As an engineer you are asked to calculate the approximate surface area of a lake in your local community. In order to do that, you decide to use a GPS to measure the x and y coord...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Problem 1 Use the trapezoidal rule technique to approximate the following integrals: a) 「(x2+1)d...

    help wanted?? thank you explain correctly Problem 1 Use the trapezoidal rule technique to approximate the following integrals: a) 「(x2+1)dr(Note: use 0.5 increments forx) b) sina d INote: use a MATLAB function to subdivide the interval into eight equal parts) c e dx (Note: use 0.25 increments for x Problem 2 Use the Simpson's rule to evaluate the following integrals aDdr Problem 3: Given the polynomial: x3-6x2 + 30-0, Use MATLAB to find all roots of this polynomial. Use MATLAB's...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT