Sie sind auf Seite 1von 1

Hayler Alberto Camargo Martı́nez.

Departamento de Fı́sica
Herramientas Computacionales
Tarea 9
1 de octubre de 2020

clear; close all; tic


m=0.2; pi=3.1416; Deltat=0.0001; Tfinal=3; t=0:Deltat:Tfinal; N=length(t);
x(1)=1.0; vx(1)=0.0; x(2)=x(1)+vx(1)*Deltat;
y(1)=0.0; vy(1)=5.0; y(2)=y(1)+vy(1)*Deltat;
z(1)=0.0; vz(1)=10.0; z(2)=z(1)+vz(1)*Deltat;
for j=3:N;
r(j-1)=sqrt(x(j-1)^2+y(j-1)^2);
x(j) = 2*x(j-1) - x(j-2) - Deltat*Deltat*(4*pi^2*x(j-1))/(r(j-1)^3);
vx(j-1) = (x(j) - x(j-2))/(2*Deltat);
y(j) = 2*y(j-1) - y(j-2) - Deltat*Deltat*(4*pi^2*y(j-1))/(r(j-1)^3);
vy(j-1) = (y(j) - y(j-2))/(2*Deltat);
z(j) = 2*z(j-1) - z(j-2) - Deltat*Deltat*(4*pi^2*z(j-1))/(r(j-1)^3);
vz(j-1) = (z(j) - z(j-2))/(2*Deltat);
end
vx(N) = (x(N)-x(N-1))/Deltat; vy(N) = (y(N)-y(N-1))/Deltat; vz(N) = (z(N)-z(N-1))/Deltat;
figure(1);clf; plot(t,x,’ko:’); grid on; xlabel(’Time’); ylabel(’x’); title(’x & t’);
figure(2);clf; plot(t,y,’ro:’); grid on; xlabel(’Time’); ylabel(’y’); title(’y & t’);
figure(3);clf; plot(t,z,’bo:’); grid on; xlabel(’Time’); ylabel(’z’); title(’z & t’);
figure(4);clf; plot(t,vx,’ko:’); grid on; xlabel(’Time’); ylabel(’vx’); title(’vx & t’);
figure(5);clf; plot(t,vy,’ro:’); grid on; xlabel(’Time’); ylabel(’vy’); title(’vy & t’);
figure(6);clf; plot(t,vz,’bo:’); grid on; xlabel(’Time’); ylabel(’vz’); title(’vz & t’);
figure(7);clf; plot(x,vx,’ko:’); grid on; xlabel(’x’); ylabel(’vx’); title(’x & vx’);
figure(8);clf; plot(y,vy,’ro:’); grid on; xlabel(’y’); ylabel(’vy’); title(’y & vy’);
figure(9);clf; plot(z,vz,’bo:’); grid on; xlabel(’z’); ylabel(’vz’); title(’z & vz’);
figure(10);clf;plot3(x,y,z,’go:’);grid on;xlabel(’x’);ylabel(’y’);zlabel(’z’);title(’Trayectoria’)
toc

Das könnte Ihnen auch gefallen