Question: Create a local user defined function, UBArea which will estimate the area from a data set: Arguments to the function will be: an array of

Create a local user defined function, UBArea which will estimate the area from a data set:
Arguments to the function will be:
an array of \( x \) values and
an array of y values
Calculations
Within the function, identify how many data pairs have been provided.
Use a for loop to calculate the area of each rectangle and sum the areas to estimate to total area under the curve.
Return the estimated area
Define a piecewise continuous function, MYFunction such that:
Arguments:
X
Calculations:
If \( X \) is less than or equal to -5.5
\(\mathrm{Y}=0.2^{*}\mathrm{X}+4.1\)
If \( X \) is greater than -5.5 but less than or equal to 5.5
\(\mathrm{Y}=0.08^{*}\mathrm{X}^{\wedge}2+5.42\)
If \( X \) is greater than 5.5
\(\mathrm{Y}=-0.4^{\star}\mathrm{X}+5.2\)
Return the value of \( Y \)
Using the MATLAB editor, create a script \( m \)-file for the following:
Define a variable K with values assigned over the range -20.5 to 13.0
Define: J = MYFunction(K)
Estimated area under the MYFunction curve accurate to 4 significant digits
Begin by assigning \(\mathrm{N}=501\) number of data points to be created
Assign preset value to UpperBound =1
Assign preset value to LowerBound \(=0\)
Using a while loop
while (UpperBound > LowerBound)
Assign values to K
Calculate values for J
Calculate the UpperBound = UBArea(\(\mathrm{K},\mathrm{J})\) and LowerBound = LBArea(\(\mathrm{K},\mathrm{J})\)
Round the UpperBound and LowerBound to 4 significant digits
Increase number of data points \( N \) by 500
end
Create a x-y scatter plot of the K-J data with title and labels.
Present the estimate of area
Create a local user defined function, UBArea

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!