function ElektronInEMField c=300000e3; qe =-1.6e-19; me =9.1093837015e-31; % Elektron E0=-1e-3; E=E0*[1 0 0]; vB =0.9*c; B0=E0/ vB ; B=B0*[0 1 0]; T0=2* pi * me / qe /B0; opts = odeset ('RelTol',1e-6); [T,Y] = ode45(@ lorentz ,[0 50*T0],[0 0 0 0 0 0], opts ); plot (T/T0,[Y(:,4)/ vB ],'Color','[0 0 0]','LineWidth',2,'DisplayName','u') hold on plot (T/T0,[Y(:,5)/ vB ],'Color','[1 0 0]','LineWidth',2,'DisplayName','v') plot (T/T0,[Y(:,6)/ vB ],'Color','[0 0 1]','LineWidth',2,'DisplayName','w') function dfdt = lorentz ( t,f ) x=f(1); y=f(2); z=f(3); u=f(4); v=f(5); w=f(6); vecv =[u v w]; gamma =1/ sqrt (1-vecv* vecv '/c^2); dvdt = qe / me / gamma *( E+cross ( vecv,B )-( vecv *E')* vecv /c^2); dfdt = [ vecv (1); vecv (2); vecv (3); dvdt (1); dvdt (2); dvdt (3)]; end end The program