Gravitational Interaction Issue with 'busy' signal

2 Ansichten (letzte 30 Tage)
Kristian Dolghier
Kristian Dolghier am 28 Apr. 2020
I'm building some code for a gratiational interaction problem. My code doesnt work becuase im still learning how code in matalb. Im trying to model the interaction of a small object and a larger planet. Basically with an object(mass of it is insignificant and cancels out) with an intial velocity in the +y direction and then trying to graph the x and y position rotating it around the planet. Any help is appretiateed becuase it seems like I have an endless while function.
%Gravitational interaction
clc, clear
close all
delta_t=.01;
G=6.67*10^-11;
M=input('Enter mass of plantet(kg): ');
R=input('Enter distance from planet(m): ');
v=input('Enter speed(m/s): ');
if (v<=0)
disp('Illegal Input')
end
theta=0;
vx=v*cosd(theta);
vy=v*sind(theta);
vx(1)=0;
x(1)=0;
i=1;
while min(R)> -.001
a(i)=G*M/R(i).^2;
vx(i+1)=vx(i)+(a(i)*delta_t);
vy(i+1)=vy(i)+(a(i)*delta_t)
x(i+1)=x(i)+vx(i)*delta_t+.5*a(i)*delta_t.^2;
y(i+1)=y(i)+vy(i)*delta_t+.5*a(i)*delta_t.^2;
R(i+1)=R(i)-x(i+1);
end
plot(R,v(i))

Antworten (0)

Kategorien

Mehr zu Gravitation, Cosmology & Astrophysics finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by