0
$\begingroup$

This list will produce a circular orbital plot:

eulerStep[{t_, state_List}, h_, f_List] := {t + h, state + h Through[f[{t, state}]]} solveSystemEuler[{t0_, state0_}, h_, n_Integer, f_List] := NestList[eulerStep[#, h, f] &, {t0, state0}, n] midptStep[{t_, state_List}, h_, f_List] := {t + h, state + h Through[ f[{t + 1/2 h, state + 1/2 h Through[f[{t, state}]]}]]} solveSytemMidPt[{t0_, state0_}, h_, n_Integer, f_List] := NestList[midptStep[#, h, f] &, {t0, state0}, n] L = 1/2 (x'[t]^2 + y'[t]^2) + 1/Sqrt[x[t]^2 + y[t]^2]; D[D[L, x'[t]], t] - D[L, x[t]] == 0 D[D[L, y'[t]], t] - D[L, y[t]] == 0 xdot[{t_, {x_, vx_, y_, vy_}}] := vx vxdot[{t_, {x_, vx_, y_, vy_}}] := -x/(x^2 + y^2)^(3/2) ydot[{t_, {x_, vx_, y_, vy_}}] := vy vydot[{t_, {x_, vx_, y_, vy_}}] := -y/(x^2 + y^2)^(3/2) start = {1, 0, 0, 1}; fcns = {xdot, vxdot, ydot, vydot}; orbit = solveSystemEuler[{0, start}, 0.01, 800, fcns]; xypts = orbit\[Transpose][[2]]\[Transpose][[{1, 3}]]\[Transpose]; ListPlot[xypts]

Orbital initial velocity is replaced by 1.25:

earthorbit=xypts;
spacestart = {1, 0, 0, 1.25};
orbit = solveSystemMidpt[{0, spacestart}, 0.01, 2200, fcns]; spacehiporbit = orbit\[Transpose][[2]]\[Transpose][[{1, 3}]]\[Transpose]; ListPlot[spacehiporbit]

Then put earth orbit on the same graph plot.

ListLinePlot[{earthorbit, spacehiporbit}, PlotStyle -> {Hue[0], Hue[0.66]}, AspectRatio -> Automatic]

I want to show is a few points along a hundred-long space orbit. i want to show 22 graphics like this but i doesn't work just the frame. Is my code correct? what's the problem?

Table[MultipleListPlot[Take[earthorbit, {n, n + 100}], Take[spaceshiporbit, {n, n + 100}], PlotJoined -> True, SymbolShape -> None, PlotStyle -> {Hue[0], Hue[0.66]}, PlotRange -> {{-3.6, 1.2}, {-2, 2}}, AspectRatio -> Automatic];, {n, 1, 2200, 100}];

then I change the code as follows:

Table[ListLinePlot[Take[earthorbit, {n, n + 100}], Take[spaceshiporbit, {n, n + 100}], PlotStyle -> {Hue[0], Hue[0.66]}, PlotRange -> {{-3.6, 1.2}, {-2, 2}}, AspectRatio -> Automatic];, {n, 1, 2200, 100}];

enter image description here

I hope someone can help me. Thank You


I want to show the graphics with codes in figure 4 from your mr. But even i tried to use your codes, it doesn't my expected.
The graphics I want as below mr. Alex Trounev

enter image description here

ListPlot[Transpose[{Column[Column[orbit,2],1],Column[Column[orbit,2],2]}],AxesLabel->{"x","Vx"}]

ListPlot[Transpose[{Column[Column[orbit,2],3],Column[Column[orbit,2],4]}],AxesLabel->{"y","Vy"}]

Mr @Alex Trounev Im sorry. This codes is very old version and i need you some help to fix this codes . sorry to make you very busy about my problem. Big thanks mr Alex Trounev.

vyvsy=Interpolation[Transpose[{Column[Column[Take[orbit,1100],2],4],Column[Column[Take[orbit,1100],2],3]}]]

vxvsx=Interpolation[Transpose[{Column[Column[Take[orbit,{550,1650}],2],2],Column[Column[Take[orbit,{550,1650}],2],1]}]]

vxvst=Interpolation[Transpose[{Column[Column[Take[orbit,-1100],2],2],Column[Take[orbit,-1100],1]}]]
$\endgroup$
  • 1
    $\begingroup$ It is difficult for the reader to advise on this question without some data to work with. $\endgroup$ – bbgodfrey Nov 2 '18 at 4:37
  • $\begingroup$ Here it's considered helpful to make the questions self sufficient, showing your own efforts and share all code in a well formatted form instead of links to external files, so we can quickly Copy&Paste your code, test it, and see the problem you are facing. Please help us to help you and edit your question accordingly. It's not fair to ask us to dig into the thread in another site to understand your problem. Which version of Mathematica are you using? $\endgroup$ – rhermans Nov 2 '18 at 9:30
  • $\begingroup$ I'm sorry..I use the mathematica version 10.3 $\endgroup$ – Teodora da Silva Nov 2 '18 at 11:11
7
$\begingroup$

The code contains several typos, after correcting which the code works. It is difficult to understand what the author wants. I understood that it is necessary to choose a certain number of points from the data (in my example, every fortieth)

eulerStep[{t_, state_List}, h_, f_List] := {t + h, 
  state + h Through[f[{t, state}]]} 
solveSystemEuler[{t0_, state0_}, h_, n_Integer, f_List] := 
 NestList[eulerStep[#, h, f] &, {t0, state0}, n] 
midptStep[{t_, state_List}, h_, f_List] := {t + h, 
  state + h Through[
     f[{t + 1/2 h, state + 1/2 h Through[f[{t, state}]]}]]} 
solveSytemMidPt[{t0_, state0_}, h_, n_Integer, f_List] := 
 NestList[midptStep[#, h, f] &, {t0, state0}, n] 
L = 1/2 (x'[t]^2 + y'[t]^2) + 
  1/Sqrt[x[t]^2 + y[t]^2]; eq = {D[D[L, x'[t]], t] - D[L, x[t]] == 0, 
  D[D[L, y'[t]], t] - D[L, y[t]] == 0}; 
xdot[{t_, {x_, vx_, y_, vy_}}] := vx 
vxdot[{t_, {x_, vx_, y_, vy_}}] := -x/(x^2 + y^2)^(3/2) 
ydot[{t_, {x_, vx_, y_, vy_}}] := vy 
vydot[{t_, {x_, vx_, y_, vy_}}] := -y/(x^2 + y^2)^(3/2) 
start = {1, 0, 0, 1}; fcns = {xdot, vxdot, ydot, vydot}; orbit = 
 solveSystemEuler[{0, start}, 0.01, 800, fcns]; xypts = 
 orbit\[Transpose][[2]]\[Transpose][[{1, 
    3}]]\[Transpose]; 
earthorbit = xypts;
spacestart = {1, 0, 0, 1.25};
orbit = solveSytemMidPt[{0, spacestart}, 0.01, 2200, 
  fcns]; spaceshiporbit = 
 orbit\[Transpose][[2]]\[Transpose][[{1, 
    3}]]\[Transpose]; 
ListLinePlot[{earthorbit, spaceshiporbit}, 
 PlotStyle -> {Hue[0], Hue[0.66]}, AspectRatio -> Automatic]

{ListPlot[{Table[earthorbit[[n]], {n, 1, Length[earthorbit], 40}], 
   Table[spaceshiporbit[[n]], {n, 1, Length[spaceshiporbit], 40}]}, 
  PlotStyle -> {Hue[0], Hue[0.66]}, 
  PlotRange -> {{-3.6, 1.2}, {-2, 2}}, AspectRatio -> Automatic], 
 ListLinePlot[{Table[earthorbit[[n]], {n, 1, Length[earthorbit], 40}],
    Table[spaceshiporbit[[n]], {n, 1, Length[spaceshiporbit], 40}]}, 
  PlotStyle -> {Hue[0], Hue[0.66]}, 
  PlotRange -> {{-3.6, 1.2}, {-2, 2}}, AspectRatio -> Automatic]}

fig1

Table[ListLinePlot[{Take[earthorbit, {n, n + 100}], 
   Take[spaceshiporbit, {n, n + 100}]}, 
  PlotStyle -> {Hue[0], Hue[0.66]}, 
  PlotRange -> {{-3.6, 1.2}, {-2, 2}}, AspectRatio -> Automatic], {n, 
  1, Min[Length[earthorbit], Length[spaceshiporbit]] - 100, 100}]

fig2 Align the data by length and create 22 patterns as the author wants.

orbit = solveSystemEuler[{0, start}, 0.01, 2200, fcns]; xypts = 
 orbit\[Transpose][[2]]\[Transpose][[{1, 3}]]\[Transpose];
earthorbit = xypts; Table[
 ListLinePlot[{Take[earthorbit, {n, n + 100}], 
   Take[spaceshiporbit, {n, n + 100}]}, 
  PlotStyle -> {Hue[0], Hue[0.66]}, 
  PlotRange -> {{-3.6, 1.2}, {-2, 2}}, AspectRatio -> Automatic], {n, 
  1, Min[Length[earthorbit], Length[spaceshiporbit]] - 100, 100}]

fig3

Coordinates and speed depending on time and speed depending on coordinate

orbit = solveSystemEuler[{0, start}, 0.01, 800, fcns];

{ListPlot[
  Table[{orbit[[i, 1]], orbit[[i, 2]][[1]]}, {i, 1, Length[orbit]}], 
  AxesLabel -> {"t", "x"}], 
 ListPlot[Table[{orbit[[i, 1]], orbit[[i, 2]][[2]]}, {i, 1, 
    Length[orbit]}], AxesLabel -> {"t", "Vx"}],
 ListPlot[
  Table[{orbit[[i, 2]][[1]], orbit[[i, 2]][[2]]}, {i, 1, 
    Length[orbit]}], AxesLabel -> {"x", "Vx"}]}

fig4
Interpolation of sample data

vyvsy = Interpolation[
   Transpose[{Take[orbit[[All, 2]][[All, 3]], 1100], 
     Take[orbit[[All, 2]][[All, 4]], 1100]}]];

vxvsx = Interpolation[
   Transpose[{Take[orbit[[All, 2]][[All, 1]], {550, 1650}], 
     Take[orbit[[All, 2]][[All, 2]], {550, 1650}]}]];

vxvst = Interpolation[
   Transpose[{Take[orbit[[All, 2]][[All, 1]], -1100], 
     Take[orbit[[All, 2]][[All, 2]], -1100]}]];

Dependencies of parameters in various combinations

orbit = 
 solveSystemEuler[{0, start}, 0.01, 800, fcns];
{ListPlot[Transpose[{orbit[[All, 1]], orbit[[All, 2]][[All, 1]]}], 
  AxesLabel -> {"t", "x"}],

 ListPlot[Transpose[{orbit[[All, 1]], orbit[[All, 2]][[All, 2]]}], 
  AxesLabel -> {"t", "Vx"}],

 ListPlot[Transpose[{orbit[[All, 1]], orbit[[All, 2]][[All, 3]]}], 
  AxesLabel -> {"t", "y"}],

 ListPlot[Transpose[{orbit[[All, 1]], orbit[[All, 2]][[All, 4]]}], 
  AxesLabel -> {"t", "Vy"}]}
{ListPlot[
  Transpose[{orbit[[All, 2]][[All, 1]], orbit[[All, 2]][[All, 2]]}], 
  AxesLabel -> {"x", "Vx"}],

 ListPlot[
  Transpose[{orbit[[All, 2]][[All, 3]], orbit[[All, 2]][[All, 4]]}], 
  AxesLabel -> {"y", "Vy"}], 
 ListPlot[Transpose[{orbit[[All, 2]][[All, 1]], 
    orbit[[All, 2]][[All, 3]]}], AxesLabel -> {"x", "y"}], 
 ListPlot[Transpose[{orbit[[All, 2]][[All, 2]], 
    orbit[[All, 2]][[All, 4]]}], AxesLabel -> {"Vx", "Vy"}]}

fig5 Another portion of the drawings. I repeat all the code so that there are no errors.

eulerStep[{t_, state_List}, h_, f_List] := {t + h, 
  state + h Through[f[{t, state}]]} 
solveSystemEuler[{t0_, state0_}, h_, n_Integer, f_List] := 
 NestList[eulerStep[#, h, f] &, {t0, state0}, n] 
midptStep[{t_, state_List}, h_, f_List] := {t + h, 
  state + h Through[
     f[{t + 1/2 h, state + 1/2 h Through[f[{t, state}]]}]]} 
solveSytemMidPt[{t0_, state0_}, h_, n_Integer, f_List] := 
 NestList[midptStep[#, h, f] &, {t0, state0}, n] 
L = 1/2 (x'[t]^2 + y'[t]^2) + 
  1/Sqrt[x[t]^2 + y[t]^2]; eq = {D[D[L, x'[t]], t] - D[L, x[t]] == 0, 
  D[D[L, y'[t]], t] - D[L, y[t]] == 0}; 
xdot[{t_, {x_, vx_, y_, vy_}}] := vx 
vxdot[{t_, {x_, vx_, y_, vy_}}] := -x/(x^2 + y^2)^(3/2) 
ydot[{t_, {x_, vx_, y_, vy_}}] := vy 
vydot[{t_, {x_, vx_, y_, vy_}}] := -y/(x^2 + y^2)^(3/2) 
fcns = {xdot, vxdot, ydot, vydot};


spacestart = {1, 0, 0, 1.25};
orbit = solveSytemMidPt[{0, spacestart}, 0.01, 2200, fcns];


{ListPlot[Transpose[{orbit[[All, 1]], orbit[[All, 2]][[All, 1]]}], 
  AxesLabel -> {"t", "x"}],

 ListPlot[Transpose[{orbit[[All, 1]], orbit[[All, 2]][[All, 2]]}], 
  AxesLabel -> {"t", "Vx"}],

 ListPlot[Transpose[{orbit[[All, 1]], orbit[[All, 2]][[All, 3]]}], 
  AxesLabel -> {"t", "y"}],

 ListPlot[Transpose[{orbit[[All, 1]], orbit[[All, 2]][[All, 4]]}], 
  AxesLabel -> {"t", "Vy"}]}


{ListPlot[
  Transpose[{orbit[[All, 2]][[All, 1]], orbit[[All, 2]][[All, 2]]}], 
  AxesLabel -> {"x", "Vx"}],

 ListPlot[
  Transpose[{orbit[[All, 2]][[All, 3]], orbit[[All, 2]][[All, 4]]}], 
  AxesLabel -> {"y", "Vy"}], 
 ListPlot[Transpose[{orbit[[All, 2]][[All, 1]], 
    orbit[[All, 2]][[All, 3]]}], AxesLabel -> {"x", "y"}], 
 ListPlot[Transpose[{orbit[[All, 2]][[All, 2]], 
    orbit[[All, 2]][[All, 4]]}], AxesLabel -> {"Vx", "Vy"}]}

fig6

$\endgroup$
  • $\begingroup$ Alex Trounev, thank you for the time to replied my questions. I have to say sorry because my problem didnt yet solve. I want to show the graphic like this but it doesnt work just the frame. are the codes is right? i need your help. Thanks you mr. ![enter image description here](i.stack.imgur.com/dDw2S.jpg) $\endgroup$ – Teodora da Silva Nov 5 '18 at 7:14
  • $\begingroup$ @TeodoradaSilva I added a line of code and fig2. $\endgroup$ – Alex Trounev Nov 5 '18 at 10:07
  • $\begingroup$ Big thanks mr. Alex Trounev really appreciate your answer because it helpfull my problem, But after i tried to running your codes, the output running just show 8 graphics, i need more graphics to completed my problem ( 22 graphics). I need your time to solve my problem again. $\endgroup$ – Teodora da Silva Nov 5 '18 at 12:51
  • $\begingroup$ The length of the orbits of the Earth and the satellite should be maintained as 800 and 2200, or can they be equalized as 2200 and 2200? $\endgroup$ – Alex Trounev Nov 5 '18 at 13:19
  • $\begingroup$ Thank you for the fast response mr Alex Trounev In this case.. I used 800 and 2200, but how the output if we used 2200 and 2200 ? $\endgroup$ – Teodora da Silva Nov 5 '18 at 14:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.