Volume of a cap (formula given) using Monte Carlo integration (MATLAB).




%%Monte
Carlo simulation for finding volume of spherical cap
clear all
close all
%function for integral
f=@(y) pi.*(4-y.^2);
%Radius and height of the spherical cap
r=2; d=1.5;
% number of points generated
N = 1000;
a1 = r-d; a2=0;
b1 = r; b2=12;
xx = a1 + (b1-a1).*rand(N,1);
yy = a2 + (b2-a2).*rand(N,1);
hits = sum(yy<=f(xx));
y1=linspace(a1,b1);
f1=f(y1);
figure(1)
plot(y1,f1,'Linewidth',2)
%Plotting data
k=0;
hold on
for i=1:N
if yy(i)<=f(xx(i))
k=k+1;
xx(k)=xx(i);
yy(k)=f(i);
plot(xx(i),yy(i),'r*')
else
plot(xx(i),yy(i),'b*')
end
end
xlim([0.5 2])
ylim([0 12])
title(sprintf('Monte Carlo plot for N=%d',N))
xlabel('x')
ylabel('y')
ar=(hits/N)*(1.5*12);
fprintf('\n\tFor N=%d volume of spherical cap using Monte Carlo
method is %f.\n',N,ar)
%Radius and height of the spherical cap
r=2; d=1.5;
% number of points generated
N = 10000;
a1 = r-d; a2=0;
b1 = r; b2=12;
xx = a1 + (b1-a1).*rand(N,1);
yy = a2 + (b2-a2).*rand(N,1);
hits = sum(yy<=f(xx));
y1=linspace(a1,b1);
f1=f(y1);
figure(2)
plot(y1,f1,'Linewidth',2)
%Plotting data
k=0;
hold on
for i=1:N
if yy(i)<=f(xx(i))
k=k+1;
xx(k)=xx(i);
yy(k)=f(i);
plot(xx(i),yy(i),'r*')
else
plot(xx(i),yy(i),'b*')
end
end
xlim([0.5 2])
ylim([0 12])
title(sprintf('Monte Carlo plot for N=%d',N))
xlabel('x')
ylabel('y')
ar=(hits/N)*(1.5*12);
fprintf('\n\tFor N=%d volume of spherical cap using Monte Carlo
method is %f.\n',N,ar)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Volume of a cap (formula given) using Monte Carlo integration (MATLAB). The volume of a cap...
Write a MATLAB script using a Monte Carlo method to estimate the volume of a 3-dimensional ball of radius R=0.5.
why are we not using the formula for h-bar given in second image in
solution of this question
HYDROSTATIC PRESSURE EXAMPLE 3.21 A circular plate of 3 m diameter is under water with its plane making an angle of 30° with water surface. If the top edge of the plate is 1 m below the water surface, find the force on one side of the plate and its location. Solution: Given d=3m 0 30 CB= 1m 1 + 1.5 x...
of MATLAS CHAPTER + An Owens Use MATLAB to calculate 6X7)+70-145 48.2855) - 9 c27310* +60(14) Check your answers with a calculator Use MATLAB to compute the following expression 16- 16-12 c. 161-12 d. 642 More UAB expression 23 d. 1003 st and smalle lculations there low and under he calculate TLAB todo the te 7. What answer is produced by the following MATLAB a. 1004-1 1004-1/2 c. 100(-1/2) The functions realmax and realmin give the largest sible numbers that...
MATLAB Create a function that provides a definite integration
using Simpson's Rule
Problem Summar This example demonstrates using instructor-provided and randomized inputs to assess a function problem. Custom numerical tolerances are used to assess the output. Simpson's Rule approximates the definite integral of a function f(x) on the interval a,a according to the following formula + f (ati) This approximation is in general more accurate than the trapezoidal rule, which itself is more accurate than the leftright-hand rules. The increased...
ICEOZA: Solving an couation using MATLAB - (isine Vester inputs) Using the Van der Waals equation of state for a real gas, we can calculate the work produced by a quantity of gas when that gas undergoes a reversible, isothermal expansion at temperature T. from initial volume V, to final volume V. That expression for reversible, isothermal work is as follows: work = ==RTI ( - ) ** ( ) where: R 0.082057; V, -1.25 V - 3.0; n10: T-800:10:...
PLEASE DO IN MATLAB
Problem 8 (PID feedback control). This problem is about Proportional-Integral-Derivative feedback control systems. The general setup of the system we are going to look at is given below: e(t) u(t) |C(s) y(t) P(s) r(t) Here the various signals are: signal/system r(t) y(t) e(t) P(s) C(s) и(t) meaning desired output signal actual output signal error signal r(t) y(t) Laplace transform of the (unstable) plant controller to be designed control signal Our goal is to design a controller...
Consider a cylindrical capacitor like that shown in Fig. 24.6. Let d = rb − ra be the spacing between the inner and outer conductors. (a) Let the radii of the two conductors be only slightly different, so that d << ra. Show that the result derived in Example 24.4 (Section 24.1) for the capacitance of a cylindrical capacitor then reduces to Eq. (24.2), the equation for the capacitance of a parallel-plate capacitor, with A being the surface area of...
i
uploaded everything that was given. Where would I find the
experiemental values?
Complete the calculation summary below. READ THE EXPERIMENTAL DISCUSSION FIRST! REPORT ALL ANSWERS TO THE CORRECT SIGNIFICANT FIGURES. SHOW CALCULATION SET-UP on the next page. PART B: Molarity Determination via Solution Stoichiometry 7.625 g Mass of Empty 50 mL Beaker 7.976 g Mass of Beaker and NaCl (final heating) Mass of NaCl Produced (Experimental Yield of NaCl) moles Moles of Na,CO, Consumed 0.00500 Liter Volume of Na,CO,...
Using the book, write another paragraph or two: write 170
words:
Q: Compare the assumptions of physician-centered and
collaborative communication. How is the caregiver’s role different
in each model? How is the patient’s role different?
Answer: Physical-centered communication involves the specialists
taking control of the conversation. They decide on the topics of
discussion and when to end the process. The patient responds to the
issues raised by the caregiver and acts accordingly. On the other
hand, Collaborative communication involves a...
Actions that damage a company and its employees should be stamped out, everyone would agree. But should the people responsible be stamped out, too? HBR CASE STUDY The Reign of Zero Tolerance by Ben Gerson "Mr. Pemberton?" manager. The guards had radioed her that the "Yes, that's me," Simon replied distractedly, his back turned. target wasn't putting up much resistance. "Your personal belongings will be messen The two burly gentlemen who had suddenly gered to your home later today," Sallie...