Montecarlo method of pi calculation
版本 1.1.0.0 (1.5 KB) 作者:
Konstantin Ninidze
Montecarlo method of pi calculation.
No loops!!!
A circle of radius 0.5 is inscribed inside a square with side length 1.
Script picks N points at random inside the square. It then checks to see if the point is inside the circle and then generates a figure in which the points ''in'' and ''out'' are plotted in different colors. Say we have M points inside the circle. Pi is then approximated as follows:
% Pi = 4*M/N.
No loops!!!
引用格式
Konstantin Ninidze (2025). Montecarlo method of pi calculation (https://www.mathworks.com/matlabcentral/fileexchange/30687-montecarlo-method-of-pi-calculation), MATLAB Central File Exchange. 检索时间: .
MATLAB 版本兼容性
创建方式
R2010b
兼容任何版本
平台兼容性
Windows macOS Linux类别
在 Help Center 和 MATLAB Answers 中查找有关 Fourier Analysis and Filtering 的更多信息
标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!