figure('name','盧瑟福散射演示'); %設定標題名字
pausetime=.002; %設定暫停時間
set(gca,'xlim',[-15 20],'ylim',[-18 18]); %設定圖片顯示坐標范圍
set(gcf,'doublebuffer','on') %消除抖動
%axis equal
hold on
plot(0,0,'color','k','marker','.','markersize',40); %畫靶原子
line([-10 -10],[-10 10],'LineStyle','-'); %入射粒子初始位置范圍
u=0:0.01*pi:2*pi;
X=14*cos(u);Y=14*sin(u);
plot(X,Y,'-k'); %環形探測器
len=0;
for n=1:100 %入射粒子數量
v0=1; %入射粒子的初速度
dr=rand;d=20*dr-10; %入射粒子的位置
end
pp=plot(0,d,'r','marker','o','markersize',5); %入射粒子的初始位置
t0=0; tf=25; x0=[v0,-10,0,d];
[t,x]=ode45('xdot',t0,tf,x0);
len=length(t);
for m=1:len
set(pp,'xdata',x(m,2),'ydata',x(m,4)); %入射粒子的即時位置
plot(x(m,2),x(m,4),'o','markersize',1);
if m==len
plot(x(m,2),x(m,4),'ok','markersize',5);
end
pause(pausetime); %暫停
drawnow
end
%subplot(1,3,1);
%plot(t,x(:,1),':b',t,x(:,2),'-r');
%subplot(1,3,2);
%plot(t,x(:,3),':b',t,x(:,4),'-r');
%subplot(1,3,3);
%plot(x(:,2),x(:,4),'-b');
Function xd=xdot(t,x)
C=1;
xd=zeros(4,1);
xd(1)=C*((x(2))^2+(x(4))^2)^(-1.5)*x(2);
xd(2)=x(1);
xd(3)=C*((x(2))^2+(x(4))^2)^(-1.5)*x(4);
xd(4)=x(3);
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/117948.html
標籤:匯編語言
上一篇:找電子標簽工廠
下一篇:維度問題
