Model a simple circular satellite orbit in time

13 visualizzazioni (ultimi 30 giorni)
So Im essentially trying to graph an orbit which will be a circle on a polar plot it is to represent the motion of a 500kg satellite when there is no force applied to it. Im neglecting the fact it should be falling over time for now. However my code does not produce the desired result so any input would be aprriciated , thank you all in advance
clc;
clear all;
G = 6.673e-11; %Gravitational constant
M = 5.98e24; %mass of earth in (kg)
ra = 100000; %orbit distance in (m)
r = 6.37e6 + ra; %total radius of orbit in (m)
m = 500; % mass satelite (kg)
a = (G*M)/(r^2); % check for acceleration
v_orb = sqrt((G*M)/r); % orbital velocity (m/s)
T = sqrt(((4*(pi^2))*r^3)/(G*M)); % period (s)
%lets graph it for the period in steps of 150 to reduce the computation
simt = T;
for t = 1:150:simt
v_o(t) = sqrt((G*M)/r);% array of velocity corresponding to time in steps of 150 .. should not change and be 1x34 - but ERROR
rn(t) = 6.37e6 + ra; % array of radius corresponding to time in steps of 150 .. should not change and be 1x34 - but ERROR
disp(t) % goes from 1 to 5101 in steps of 150
%%% create array of the form 1x34 corresponding to t ???? %%%
end
figure
plot(t, v_o); xlabel('Simulation Time', 'FontSize', 12);
ylabel('Velocity', 'FontSize', 12);
grid; %%% expecting a graph of straight line %%%
figure
plot(t, rn); xlabel('Simulation Time', 'FontSize', 12);
ylabel('Radius', 'FontSize', 12);
grid; %%% expecting a graph of straight line %%%
%%% take the points of radius and time convert to polar coordinates and plot %%%
%%% expecting a circle as satellite moves around the orbit of constant radius in a sice of time of the period%%%
%[theta,rho] = cart2pol(t,rn);
theta = atan2(rn,t);
rho = sqrt((t.^2)+(rn.^2));
theta= theta*(180/pi); % to degrees
figure
polarplot(theta,rho)
title('Orbit')

Risposta accettata

James Tursa
James Tursa il 3 Feb 2020
Since you are setting up a circular orbit, just scale the time by the period to get theta. E.g., since one period would be an angle of 2pi,
theta = 2*pi * t / T;
Then just use that and rn for your plot.
  2 Commenti
Michal Sleszynski
Michal Sleszynski il 3 Feb 2020
Modificato: Michal Sleszynski il 3 Feb 2020
So what you mean is instead of
theta = atan2(rn,t); -> theta = 2*pi * t / T;
still though t is not an array and v_o and rn are the wrong size instead f 1x34 , 1x5101
both v_o and rn have thier first value and then follow by 5100 zeros.
Michal Sleszynski
Michal Sleszynski il 3 Feb 2020
Ive changed a bit and took your advice thank you very much. My final answer is bellow.

Accedi per commentare.

Più risposte (2)

Michal Sleszynski
Michal Sleszynski il 3 Feb 2020
This is my final code and it seems to work now:
Untitled.png
clc;
clear all;
G = 6.673e-11; %Gravitational constant
M = 5.98e24; %mass of earth in (kg)
ra = 100000; %orbit distance in (m)
r = 6.37e6 + ra; %total radius of orbit in (m)
m = 500; % mass satelite (kg)
a = (G*M)/(r^2); % check for acceleration
v_orb = sqrt((G*M)/r); % orbital velocity (m/s)
T = sqrt(((4*(pi^2))*r^3)/(G*M)); % period (s)
%lets graph it for the period in steps of 150 to reduce the computation
steps = T/35;
simt = -steps;
for i = 1:1:36
simt = simt+steps;
t(i) = simt;
v_o(i) = sqrt((G*M)/r);% array of velocity corresponding to time in steps of 150 .. should not change and be 1x34 - but ERROR
rn(i) = 6.37e6 + ra; % array of radius corresponding to time in steps of 150 .. should not change and be 1x34 - but ERROR
%disp(t2) % goes from 1 to 5101 in steps of 150
end
figure
plot(t, v_o); xlabel('Simulation Time', 'FontSize', 12);
ylabel('Velocity', 'FontSize', 12);
grid; %%% expecting a graph of straight line %%%
figure
plot(t, rn); xlabel('Simulation Time', 'FontSize', 12);
ylabel('Radius', 'FontSize', 12);
grid; %%% expecting a graph of straight line %%%
%%% take the points of radius and time convert to polar coordinates and plot %%%
%%% expecting a circle as satellite moves around the orbit of constant radius in a sice of time of the period%%%
%[theta,rho] = cart2pol(t,rn);
%th = atan2(rn,t);
th = 2*pi * t / T;
rho = sqrt((t.^2)+(rn.^2));
%disp(th);
figure
polar(th,rho)
title('Orbit')

Meysam Mahooti
Meysam Mahooti il 26 Mag 2021
Modificato: James Tursa il 26 Mag 2021

Categorie

Scopri di più su Reference Applications in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by