1. Engineering
  2. Computer Science
  3. erview n this exercise you will write a code which...

Question: erview n this exercise you will write a code which...

Question details

erview n this exercise, you will write a code which can numerically approximate the integral of the function fx) Func over the interval [a,b] using a middle Riemann Sum with N steps, d using MATLABs integral function. The code should also output the error between the two calculated areas. unction Inputs Func - the function to be numerically integrated. the lower interval value b- the upper interval value the number of rectangles to be used. Function Outputs rea_Riemann- the numerical approximation for the area under the curve using a middle Riemann sum. rea_integral- the numerical approximation for the area under the curve using the integral function. Error the error between the two area calculations (take the absolute value to ensure this is always positive). cess: Step 1: Solve Area_Riemann - consult your answer from Q3 of last weeks exercises Step 2: Solve Area_integral - consult your answer from Q1 of last weeks exercises Step 3: Solve Error -this should be the absolute value of the difference between the two areas. Useful Functions: 1linspace, sum, abs unction Template function [Area_Riemann, Area_integral, Error]-area(Func, a, b,N) INSERT CODE Submitted file: function [Area_Riemann, Area_integral,Error]-area (Func,a,b,N) x - linspace(a, b,N+1); h = (b-a)/N; yFunc(x(1:N)+h/2); Area Riemann = abs(sum(y*h)); Area_integral - integral(Func, a,b); Error-abs (Area_integral Area_Riemann) en

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution