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...


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<br>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<br>reclangke. The igure below shows this approximalion with an incronent el 1 and the tunclion being evaluabed al he midpaint of he increment.<br>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.<br>Wto the code hat will calculate the area under the curve:<br>Vina)+ 0.5-<br>(wheru x is in radians<br>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<br>of 1. Decrease the increment by half every iteration.<br>

Extracted text: 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.
Start<br>dePine terms<br>inc set to one<br>Slope I- calculate using definte loop fron Fa<br>Slope2 sct to zero<br>initialize a<br>Counter<br>52=D0<br>%3D<br>2 =4<br>(use indetante / elagel slapeh<br>loop<br>slapel slopeh<br>(diffrence > 0.01%6<br>divide inc by 2<br>S=45<br>52=45<br>$z=4.27<br>ol farsl fime<br>Check:f<br>set slopel eqyak to slape?<br>Use a defnide loop fam Fa<br>to find the slope<br>Courtler not zcre<br>recatautte s tope2<br>increpent the Conter<br>Usang nen inc<br>lend<br>

Extracted text: 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
Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here