If we have a data set consisting of N data pairs: xn,ynthere will be N-1 intervals between data pairs.
In the above diagram, the lessor of the two edges has been selected for the y value of the rectangle, and the width of the rectangle is xn-1– xn
We can therefore write the estimated area as:
Write a MATLAB function and save a file with name Area which will estimate the area from a data set:
Arguments to the function will be:an array of x values andan array of y valuesCalculationsIdentify how many data points have been provided in array x.Initialize the estimated area variable to zero.Use a for loop which counts n from 1 to (data point count -1)Determine width of rectangleDetermine height of rectangleCalculate the area of the rectangleand add to estimate for areaendReturn the estimated area
Arguments to the function will be:
an array of x values andan array of y values
Calculations
Identify how many data points have been provided in array x.Initialize the estimated area variable to zero.Use a for loop which counts n from 1 to (data point count -1)Determine width of rectangleDetermine height of rectangleCalculate the area of the rectangleand add to estimate for areaend
Use a for loop which counts n from 1 to (data point count -1)
Determine width of rectangleDetermine height of rectangleCalculate the area of the rectangleand add to estimate for area
and add to estimate for area
Return the estimated area
Using the MATLAB editor, create a script m-file for the following:
Read thedata fileand assign values to arrays.Create a x-y scatter plot of the data with title and labels.Calculate the estimated area under the curve.Present the estimate of area
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here