Matlab Code % Problem Statement - The area under a curve can be estimated by breaking % the x-axis into increments, evaluating the function at a point inside % that increment, and approximating the area under the curve in that % increment as a rectangle. %% Housekeeping Commands clc
Matlab Code
% Problem Statement - The area under a curve can be estimated by breaking
% the x-axis into increments, evaluating the function at a point inside
% that increment, and approximating the area under the curve in that
% increment as a rectangle.
%% Housekeeping Commands
clc
clear
%% Variables to be used
% Inputs
% Xmin - the minimum limit of the range
% Xmax - the maximum limit of the range
% Outputs
% area - the final approximation of the area under the curve for the given range
%% Inputs
% This generates the scalars, Xmin and Xmax, with random values which will be used to evaluate your code
% Xmin=randi(5)
% Xmax=Xmin+randi([5 10])
% Test Case 1
Xmin = 0;
Xmax = 10;
% Test case output:
% area = 131.3823
%% Start Programming
![Problem Statement
The area under a curve can be estimaled by breaking the x asis into increments, evakualing the luncian at a point insice that incrament, and approximating the area under the curve in that incrament as a
reclangke. The igure below shows this approximalion with an incronent el 1 and the tunclion being evaluabed al he midpaint of he increment.
As the increment deoreases, the approsimation of the aren undor the ourve improves as shown when the ineroments are deereased to 0.25 for the same tunetion as shown abeve.
Wto the code hat will calculate the area under the curve:
Vina)+ 0.5-
(wheru x is in radians
using decreasing increments until the aren value converges (the difference between the area from two onsecutive runs is less than 0.01%). Use the midpoint approximation method and start with an increment
of 1. Decrease the increment by half every iteration.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F0d1d82f5-6dbd-4a85-bd51-7ea53cf9931f%2Fde03df67-5483-4e16-a327-551a20e5b54d%2F2suee2u_processed.png&w=3840&q=75)
![Start
dePine terms
inc set to one
Slope I- calculate using definte loop fron Fa
Slope2 sct to zero
initialize a
Counter
52=D0
%3D
2 =4
(use indetante / elagel slapeh
loop
slapel slopeh
(diffrence > 0.01%6
divide inc by 2
S=45
52=45
$z=4.27
ol farsl fime
Check:f
set slopel eqyak to slape?
Use a defnide loop fam Fa
to find the slope
Courtler not zcre
recatautte s tope2
increpent the Conter
Usang nen inc
lend](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F0d1d82f5-6dbd-4a85-bd51-7ea53cf9931f%2Fde03df67-5483-4e16-a327-551a20e5b54d%2F44d5hfo_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)