Jump to content

Learning MatLab - Plotting an Orbit

Featured Replies

I'm trying to write a Matlab (well.. octave) code to plot the tradjectory of a satellite in orbit.

 

Unfortunately it just keeps drawing a diagonal line, but I can't for the life of me work out why it wont do any type of "proper" orbit.

 

I think it's nearly there as if I "drop" the satelite (no tangental velocity) it does a sort of 1D elipse.

 

I've attatched the file anyway (renamed .m to .txt as uploader didn't like) if somebody could have a look I would be very appreciative.

 

 

I'm using the following to work out trajectories (given in question);

 

[Math]

r(t + \delta t) = 2r(t) - r(t-\delta t) + \delta t^2 * F(t)/m...............and.......

\\

\\

v = 1/(2 \delta t)*x(t+\delta t) - x(t-\delta t))

[/Math]

 

F, r, and v are 3D vectors for the Force, posion and velocity respectively.

 

I'm plotting the x and z values of r(x,y,z)- to try and generate a loop, elipse etc of a 2D orbit.

Orbit2.txt

  • Author

OK turns out it is working... sort of. My point was being sucked into the black hole and then the programme got upset and decided to spit it out creating a massive line that dwarfed the orbit before being "sucked in".

 

However- the orbits still seem a little odd though- the origin of the black hole (0,0) is far too close to the elipse IMO.

 

If somebody could take a look it'd be really good.

 

I've attatched some pics and the altered code for a reasonable orbit. If you want to change the "starting velocties" change r and/ or rOld, in units of about 100- there is not explicit starting velocity that changes the tradjectory (it is effectively (r-rOld)/dt).

 

You can increase the "length" of the orbit it is showing by changing t.

Orbit2 (2).txt

Launch into Elipse.jpg

Launch into escape.jpg

Launch into wierd orbit then escape.jpg

Precessional Elipse.jpg

Archived

This topic is now archived and is closed to further replies.

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.