Model a simple circular satellite orbit in time

조회 수: 48 (최근 30일)
Michal Sleszynski
Michal Sleszynski 2020년 2월 2일
편집: James Tursa 2021년 5월 26일
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')

채택된 답변

James Tursa
James Tursa 2020년 2월 3일
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
Michal Sleszynski
Michal Sleszynski 2020년 2월 3일
편집: Michal Sleszynski 2020년 2월 3일
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 2020년 2월 3일
Ive changed a bit and took your advice thank you very much. My final answer is bellow.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Michal Sleszynski
Michal Sleszynski 2020년 2월 3일
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 2021년 5월 26일
편집: James Tursa 2021년 5월 26일

카테고리

Help CenterFile Exchange에서 CubeSat and Satellites에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by