Question: (Matlab) Convert the code below (Area Calculation) into the functions as described below: (1) Area calculation with Monte-Carlo simulation function [AreaSim]=monte_area(Curve, Range, NOP) wherein the
(Matlab) Convert the code below (Area Calculation) into the functions as described below:
(1) Area calculation with Monte-Carlo simulation
function [AreaSim]=monte_area(Curve, Range, NOP)
wherein the function output AreaSim is the area calculated, the inputs Curve is the equation of the curve, Range is the starting and ending value, NOP is the number of points (darts) you used to calculate.
%------------------------------------------------------%
N=10000;
Landed=0;
for i=1:N
x=rand()*16;
y=rand()*10;
if(y<2*sqrt(x)+1)
Landed=Landed+1;
end
end
area=10*16*(Landed/N)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
