I've been using MATLAB (ode45) to simulate the mechanics of a rocket under the forces of gravity, drag, and internal thrust.y I've recently refactored my simulation to include 2d space, orientation of the rocket, etc. (So I can try to make it orbit, finding optimal ascent profiles, etc)(adsbygoogle = window.adsbygoogle || []).push({});

Because I want to retain the simplicity of my 1d model, I've attempted to use polar coordinates for defining the rockets position, velocity, and acceleration. I've implemented it, but when I run the simulation and plot height vs theta... I get a disturbing picture.

Gravity does not affect the orbital velocity in any way. It always accelerates the height of the rocket downward. And yet for it to orbit, it needs to have a cyclic, non-zero height. Something is very wrong here, and I can't tell what it is.

The line defining gravitational acceleration is as follows. I define it as a vector, with the first component being orbital acceleration (how much theta's rate of change changes due to gravity), and the second component being height's acceleration. (height is y, here)

Since S (the standard gravitation parameter) is positive, the acceleration of height will always be negative. The height of the rocket must inevitably go to zero. My intuition of gravity no longer makes sense.Code (Text):grav = [0; -S/(R+y)^2];

This is bothering me on a visceral level. I can't tell what I'm doing wrong. I now suspect the Earth will fall into Sol in the next few hours.

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# MATLAB [MATLAB] Modeling gravity using polar coordinates! Argh!

**Physics Forums | Science Articles, Homework Help, Discussion**