数学建模数模第一次作业(章绍辉版).pdfVIP

  • 15
  • 0
  • 约7.53千字
  • 约 9页
  • 2023-06-15 发布于上海
  • 举报
1.(1) n=101; x1=linspace(-1,1,n); x2=linspace(-2,2,n); y1=[sqrt(1-x1.^2);-sqrt(1-x1.^2)]; y2=[sqrt(4-x2.^2);-sqrt(4-x2.^2);sqrt(1-(x2.^2)/4);-sqrt(1-(x2.^2)/4) ]; plot(x1,y1) hold on; plot(x2,y2) title(椭圆 x^2/4+y^2=1 的内切圆和外切圆) axis equal 椭圆x2 2 /4+y =1的内切圆和外切圆 2 1.5 1 0.5 0 -0.5 -1 -1.5 -2 -2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5 (2) x1=linspace(-2,2,101); x2=linspace(-2,8); axis equal plot(exp(x1),x1,x1,exp(x1),x2,x2) title(指数函数y=exp(x)和对数函数y=ln(x)关于 y=x 对称) 1 / 9 指数函数y=exp(x)和对数函数y=ln(x)关于y=x对称 8 7 6 5 4 3 2 1 0 -1 -2 -2 -1 0 1 2 3 4 5 6 7 8 (3) hold on q=input(请输入一个正整数q;) for i=1:q for j=1:i if rem(j,i) plot(j/i,1/i) end end end 2 / 9 0.5 0.45 0.4 0.35 0.3 0.25 0.2 0.15 0.1 0.05 0 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 3.代码如下: n=input(请输入实验次数n=) k=0; for i=1:n x=ceil(rand*6)+ceil(rand*6); if x ==3|x==11 k=k+1; elseif x~=2x~=7x~=12 y= ceil(rand*6)+ceil(rand*6); while y~=xy~=7 y=ceil(rand*6)+ceil(rand*6); end if y==7 k=k+1; end end end 3 / 9 更改试验次数n的值,打赌者赢得概率w随n的变化情况如下: 试验次数n 打赌者赢得概率w 1000 0.5280 1500 0.4953 2000

文档评论(0)

1亿VIP精品文档

相关文档