Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Convert to Real Time

Subject: Convert to Real Time

From: Brendan

Date: 9 Apr, 2010 13:20:24

Message: 1 of 1

Hi,
This isnt a very "code" oriented question, but Im developing a code to simulate a body travelling under a central force. The units for distance I am using are in A.U for convenience, but Im trying to convert the time over which the simulation takes place back into real time for presentation sake. So say for example I have:

z=[x_position; y_position; x_velocity; y_velocity]
Time=zeros(1110,1) %create zero vector to hold the times
tend=0.1
for i=1:100
[t,z]=ode45(@twobodyfunctionmars,[0:0.01:tend],z0,options);
Time(1:length(z))=t(:,1);
end

now, Ive used:
Time_total=length(Time)*0.01

to find the total time over which the problem has been solved.
Lets say the total time I get for a given orbit is 15.63 seconds using a time step of 0.01.
Could anyone tell me the best way to convert this to real time, i.e. years? I've done it for Mars's orbit and got some crazy answer. Basically I divided time_total by 1 metre(in A.U). I must be making a mistake.
Apologies if this post doesnt seem relevant to Matlab.
Thanks
Brendan

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us