Struggling to write t0 from sometime ago

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Struggling to write t0 from sometime ago

Mphumzi Tshentu
Would please help me, I tried to write t0 from 09h27min35sec in 17 February 2002. I want to get the time elapsed from that date up to a certain date later , for an example 13h22min40sec in 18 June 2004.

I tried writing in the following way and tried several other ways I don't seem to get it right.

octave-3.2.4.exe:1> t0=(clock(09:27:35),17-Feb-02

parse error:

 

  syntax error






octave-3.2.4.exe:1> t0=(clock(09:27:35) 17-Feb-02

Would you please help

Thanks

Mphumzi







_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Struggling to write t0 from sometime ago

Kire Pudsje

On Fri, Aug 18, 2017 at 7:42 PM, Mphumzi Tshentu <[hidden email]> wrote:
Would please help me, I tried to write t0 from 09h27min35sec in 17 February 2002. I want to get the time elapsed from that date up to a certain date later , for an example 13h22min40sec in 18 June 2004.

I tried writing in the following way and tried several other ways I don't seem to get it right.

octave-3.2.4.exe:1> t0=(clock(09:27:35),17-Feb-02


I would use a datenum.
days from your date reference up to now:
now-datenum(2002,2,17,9,27,35)
fractional part will be like fractional days, so times 24 is hours.
 

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Struggling to write t0 from sometime ago

Andreas Weber-6
In reply to this post by Mphumzi Tshentu
Am 18.08.2017 um 19:42 schrieb Mphumzi Tshentu:
> Would please help me, I tried to write t0 from 09h27min35sec in 17
> February 2002. I want to get the time elapsed from that date up to a
> certain date later , for an example 13h22min40sec in 18 June 2004.

This page may help which shows the different time formats and the
conversion between them.

http://wiki.octave.org/Date/Time_functions

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Struggling to write t0 from sometime ago

NJank
In reply to this post by Mphumzi Tshentu


On Fri, Aug 18, 2017 at 1:42 PM, Mphumzi Tshentu <[hidden email]> wrote:
Would please help me, I tried to write t0 from 09h27min35sec in 17 February 2002. I want to get the time elapsed from that date up to a certain date later , for an example 13h22min40sec in 18 June 2004.


ok, that's much more clear. you should understand that you need to follow basic programming syntax, so parentheses must be closed ( ( ) ).  that's why you got the syntax error.

for your actual usage,  learn about date counting in the Octave help
https://www.gnu.org/software/octave/doc/v4.0.0/Timing-Utilities.html#Timing-Utilities

something like the following should work for you:

>> t0 = datenum(2002, 2, 17, 09, 27, 35)
t0 =   7.3126e+005

>> t1 = datenum(2004, 6, 18, 13, 22, 40)
t1 =   7.3212e+005

>> days_elapsed = t1-t0
days_elapsed =  852.16

>> approximate_years_elapsed = dayselapsed / 365.25
approximate_years_elapsed =  2.3331

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Struggling to write t0 from sometime ago

shall689
In reply to this post by Mphumzi Tshentu
According to the documentation, the clock function doesn't have any parameters.

Why not subtract their datenum value from each other to get the total number of days.

Function File: days = datenum (datevec)
Function File: days = datenum (year, month, day)
Function File: days = datenum (year, month, day, hour)
Function File: days = datenum (year, month, day, hour, minute)
Function File: days = datenum (year, month, day, hour, minute, second)
Function File: days = datenum ("datestr")
Function File: days = datenum ("datestr", f)
Function File: days = datenum ("datestr", p)
Function File: [days, secs] = datenum (…)

Stephen