蒲丰投针的Mathematica实现求代码,我自己编了一个,但出不来,程序如下F[n_] :=(For[i = 1,i < n,i++,x = Random[-5,5];y = Random[-5,5];a = Random[0,2 Pi];x1 = x + 0.25 Sin[a]; x2 = x - 0.25 Sin[a];y1 = y + 0.25 Cos[a]; y2 = y - 0.25

来源:学生作业帮助网 编辑:作业帮 时间:2024/10/05 15:56:56
蒲丰投针的Mathematica实现求代码,我自己编了一个,但出不来,程序如下F[n_] :=(For[i = 1,i < n,i++,x = Random[-5,5];y = Random[-5,5];a = Random[0,2 Pi];x1 = x + 0.25 Sin[a]; x2 = x - 0.25 Sin[a];y1 = y + 0.25 Cos[a]; y2 = y - 0.25
xT[kG+ hw(,Cq@؅>,K4kyWhWtevlv$uۤ&5ŗT?7~3 ynsΜL%<+hEwwn.Y|,:ڿ/Qu?</~ Z4Qi=}wF)h"y`U5*ݔDd":9\XkUJ4 ! #U*R<*Ҥ$_W55g$WRԼeԺQYɞ'}_GRo1ڈ/n(!VI]ˡ=128#)22R}Zsiɀ>g4C%\\HJ2J[Ex# 2Ƃ+#yꊏ֗ϣ><;*g|}R+GzNl9+397)3Mϧe_Ƌ= xנJGhwlQrz~ VzJ/'!9<;~9>~܇043J6?#& #(<Z;@e'?y V%w7X.Kxm퇯:41"K\aƭi|6K59_yByAztpY"Mn `88E!xd"Fغq,"X=WV}fc2 $&++ ʜiZ**-p'"c  !p;eaU0RC$ɈR@i Md4EJ %[cz:؃ ]{^zep8ubop۬@ʶ0m)\F觼!REΤ 1Gp

蒲丰投针的Mathematica实现求代码,我自己编了一个,但出不来,程序如下F[n_] :=(For[i = 1,i < n,i++,x = Random[-5,5];y = Random[-5,5];a = Random[0,2 Pi];x1 = x + 0.25 Sin[a]; x2 = x - 0.25 Sin[a];y1 = y + 0.25 Cos[a]; y2 = y - 0.25
蒲丰投针的Mathematica实现
求代码,我自己编了一个,但出不来,程序如下
F[n_] :=
(For[i = 1,i < n,i++,
x = Random[-5,5];
y = Random[-5,5];
a = Random[0,2 Pi];
x1 = x + 0.25 Sin[a]; x2 = x - 0.25 Sin[a];
y1 = y + 0.25 Cos[a]; y2 = y - 0.25 Cos[a];
CC = Array[A,9];
For[j = 1,j < 10,j++,y3[x] := j - 5;
A[j] = Which[x < -5,0,-5 < x < 5,y3[x],x > 5,0]]
aa = {{x1,y1},{x2,y2}};
AA = Fit[aa,{1,x},x];
BB = Which[0 < a < Pi,
Which[x < x2,0,x2 < x < x1,AA,x > x1,0],Pi < a < 2 Pi,
Which[x < x1,0,x1 < x < x2,AA,x > x2,0]];
CC = Join[CC,BB]];
Return[CC])
Manipulate[
ListPlot[F[n]
AspectRatio -> Automatic]],{nn,1,730}]
如果各位牛人能给我指出错误也行,
老师要求能仿真出来,就是一个框里逐渐出现针.

蒲丰投针的Mathematica实现求代码,我自己编了一个,但出不来,程序如下F[n_] :=(For[i = 1,i < n,i++,x = Random[-5,5];y = Random[-5,5];a = Random[0,2 Pi];x1 = x + 0.25 Sin[a]; x2 = x - 0.25 Sin[a];y1 = y + 0.25 Cos[a]; y2 = y - 0.25
(*你老师也太事多了,我不打算再细做了,剩下的细节你自己完成好了*)
Manipulate[
bizhi = 针长/平行线距离;
shuju = Table[{RandomReal[平行线数],RandomReal[平行线数],
RandomReal[Pi/2]},{ii,1,投掷次数}];
shuju2 =
Cases[shuju,{ii_,jj_,
kk_} -> {{ii,jj},{ii + bizhi*Cos[kk],jj + bizhi*Sin[kk]}}];
shuju3 = Select[shuju2,Floor[#[[2,2]]] - Floor #[[1,2]] > 0 &];
shum = Length[shuju2];
xianarray = Table[{{0,ii},{平行线数 + 0.5,ii}},{ii,0,平行线数,1}];
Show[{ListLinePlot[xianarray],ListLinePlot[shuju2]},
AspectRatio -> Automatic,
PlotRange -> {{0,平行线数 + 0.5},{0,平行线数 + 0.5}},
Axes -> False],{针长,1,5,1},{平行线距离,1,10,1},{投掷次数,1,100,
1},{平行线数,2,10,1}]