Home > other >  Does anyone help to look at the error
Does anyone help to look at the error

Time:10-08

Figure (' name ', 'rutherford scattering demo'); % set title name
Pausetime=. 002; % set pause time
Set (gca, 'xlim, 20 [15],' ylim, [18] - 18); % set image coordinates range
Set (GCF, 'doublebuffer', 'on') % to eliminate jitter
% axis equal
Hold on
The plot (0, 0, 'color', 'k', 'marker', '. ', 'markersize', 40). % painting target atom
Line (10-10 [-], [10] 10, 'graphics.linestyle', '-'); % the scope of the initial position of incident particles
U=0-0. 01 * PI: 2 * PI;
X=14 * cos (u); Y=14 * sin (u);
Plot (X, Y, '- k); % ring detector
Len=0;
For n=1 to 0% the number of incident particles
Where v0=1; % initial velocity of the injected particle
Dr=rand; D=20 * Dr - 10; The location of the incident particles
%End
Pp=plot (0, d, 'r', 'marker', 'o', 'markersize', 5); The initial position of the injected particle %
T0=0; Tf=25; X0=[where v0, -, 0, 10 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)); % the real-time location of incident particles
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); % to suspend
Drawnow
End
% subplot (1,3,1);
% the plot (t, x (:, 1), ':' b, t, x (:, 2), '-r');
% subplot 31 (1);
% the plot (t, x (:, 3), ':' b, t, x (:, 4), '-r');
% subplot (1 filling);
% the plot (x (:, 2), x (:, 4), 'b');
The Function of 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);
  • Related