作业帮 > 综合 > 作业

matlab (1)选取10000对随机的a,b,根据(a,b)=1的概率求出圆周率的近似值 (2)用Monte Car

来源:学生作业帮 编辑:拍题作业网作业帮 分类:综合作业 时间:2024/05/26 22:36:30
matlab (1)选取10000对随机的a,b,根据(a,b)=1的概率求出圆周率的近似值 (2)用Monte Carlo方法计算圆周率
不要拿不能用的代码糊弄我...发到594783107@.com
第一题:
temp.m
clear all
clc
s=0;
for n=1:10000.
a=ceil(rand(1)*10000);
b=ceil(rand(1)*10000);
p=a;q=b;
if(p>
第二题:::用Monte Carlo方法计算圆周率
输入:temp.m
clear all
clc
s=0;
for n=1:100000
r1=rand(1);
r2=rand(1);
if r1^2+r2^2