[Mathematical Modeling] Mathematical Modeling for National College Students in 2018 - Design of Thermal Protective Clothing (with some MATLAB code)

Introduction to Monte Carlo Methods

Monte Carlo (Monte Carlo,  abbr . MC) method is a method of solving physical and mathematical problems using independent repeated statistical experiments. A simple application of the MC method is to find the area of ​​a graph .

See the complete code

Practical application case: Design of thermal protective clothing Monte Carlo method to solve heat conduction equation (MATLAB implementation)

Example: Area to be solved ?

%投点次数
M = 1000;
A = rand(M,2);
r = sqrt((A(:,1) - 0.5).^2 + (A(:,2) - 0.5).^2);
total = sum(r < 0.5);
pr = total / M;
disp(pr)

%绘图
xt = @(t) 0.5*cos(t) +0.5;
yt = @(t) 0.5*sin(t) + 0.5;
fplot(xt,yt)
hold on
plot(A(:,1),A(:,2),'.');
grid on
axis equal
axis([0,1,0,1])

Calculated result: 0.7630

Guess you like

Origin blog.csdn.net/wenyusuran/article/details/123473296