How can I plot the orbit of Earth over the course of a year using Julian dates?

2 ビュー (過去 30 日間)
Rebekah Ericson
Rebekah Ericson 2020 年 11 月 13 日
編集済み: Cris LaPierre 2020 年 11 月 13 日
The error I get:
Unrecognized function or variable 't_0'.
Error in MHCP_parametricEarth (line 2)
t = linspace (t_0,(1/366),t_0+1);
What I am attempting to do:
Graph the orbit of Earth over 1 year so that its path over a day shows up every 0.01 seconds.
My code:
t_o = juliandate(2020,10,13);
t = linspace (t_0,(1/366),t_0+1);
x=150*cos(2*pi(t-t_o));
y=150*sin(2*pi(t-t_o));
tcounter=0;
while tcounter<=1
plot([x(tcounter) x(tcounter + 1/365)], [y(tcounter) y(tcounter + 1/365)])
tcounter = tcounter + 2/365
pause(0.01)
end
  1 件のコメント
Rebekah Ericson
Rebekah Ericson 2020 年 11 月 13 日
Thank you for the answer. I have changed that and edited my code, but it is still not plotting right. It will run, but it's not giving a graph or anything. It will just store numbers in the workspace, and t, x, and y are all 1 by 0 vectors here.
jd = juliandate(2020,10,13)
t_0 = jd
jd_2 = juliandate(2021,10,13)
t_1 = jd_2
t = linspace (jd, jd_2, 1/366)
x=150*cos(2*pi*(t-t_0));
y=150*sin(2*pi*(t-t_0));
tcounter=t_0;
while tcounter<=1
plot([x(tcounter) x(tcounter+1/365)], [y(tcounter) y(tcounter + 1/365)])
hold on
tcounter = tcounter + 2/365
pause(0.01)
end

サインインしてコメントする。

採用された回答

Cris LaPierre
Cris LaPierre 2020 年 11 月 13 日
The error you shared is because you defined t_o (uses the letter O), but then try to calculate something using t_0 (uses the number 0).
  2 件のコメント
Cris LaPierre
Cris LaPierre 2020 年 11 月 13 日
Pretty soon, you're going to encounter the following error:
  • Array indices must be positive integers or logical values.
See my answer here.
Cris LaPierre
Cris LaPierre 2020 年 11 月 13 日
編集済み: Cris LaPierre 2020 年 11 月 13 日
Check your while loop condition. What is the value of t_0 just before the loop begins?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEnvironment についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by