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

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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.
Transcribed Image 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
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
Transcribed Image 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
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY