I need help figuring the code out.

1 view (last 30 days)
Kelsey Dugger
Kelsey Dugger on 2 Mar 2021
Answered: Walter Roberson on 3 Mar 2021
Find the area enclosed by y = e^x , y = x, x = 0, and x = 2 please help me code this problem please
  2 Comments
the cyclist
the cyclist on 2 Mar 2021
Please read this advice about how to get your question answered quickly here.
Cris LaPierre
Cris LaPierre on 2 Mar 2021
You may be mistaken on what MATLAB Answers is. This is not a MATLAB coding service. We are here to answer your MATLAB questions.
If you need help getting started, consider completing MATLAB Onramp.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 3 Mar 2021
You can use a Monte Carlo method:
format long g
R = randi([2 3])
R =
3
xy = rand(10000,2) * exp(R);
x = xy(:,1); y = xy(:,2);
mask = y <= exp(x) & y >= x & x <= 2;
portion = mean(mask)
portion =
0.0121
area = portion * exp(R).^2
area =
4.88148840126209

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!