I'm working on writing my own orbital dynamics code; when I go to calculate the difference between two data points, I get different answers. Basically the logic is: change = new position - (old position + velocity*time); this yields a result of 0, which is not correct. I switched it to the following: change1 = new pos - old pos; change = change1 - velocity*time; which gives me a non-zero result with the correct magnitude. Its the same calculation, but I get different results!
I then try to calculate the same difference for a different planet, and while both answers are non-zero, they both differ from each other by a factor of 10^-6...
Should I change my different planet's code the same way I changed the first?

댓글 수: 2

Geoff Hayes
Geoff Hayes 2016년 4월 4일
Niklas - can you post some of your code? Also, what data types are you using for your variables? Are they doubles, singles, unsigned integers, or ... ?
Niklas Anthony
Niklas Anthony 2016년 4월 4일
Everything is double;
system = [obj;earth;moon];%matrix of every object's pos and vel (3x6)
o_n_s = stepxyz(system(1,:),t,Ms);
%o_n_s is vector of pos & vel values (1x6)
%want to find the effects of gravity compared to zero-acceleration path
%the first two lines are the change i made, but the y and z havent been changed - results non-zero
dx_o_s = (o_n_s(1) - system(1,1));
dxo_s = dx_o_s - system(1,4)*t;
%this is the original line of code - results in 0
dx_o_s = o_n_s(1) - (system(1,1) + (system(1,4)*t));

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

 채택된 답변

the cyclist
the cyclist 2016년 4월 4일

0 개 추천

My guess is that you are seeing this.

추가 답변 (0개)

제품

태그

질문:

2016년 4월 4일

댓글:

2016년 4월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by