From: Karan on 1 Sep 2007 11:52 I was wondering if anyone can help me with this Have a huge vector of serial date time and i wish to compute the difference between each element of the vector with the next element. Basically the pseudo command is something like this find(diff(serial_Time_vector)>1800 seconds) I wish to find the index numbers in the vector where the difference is greater than 30 minutes. Whats the quickest way to do this? Thanks Karan
From: Lorenzo on 1 Sep 2007 12:41 "Karan " <ksumbaly(a)hotmail.com> wrote in message <fbc1rh$6n$1(a)fred.mathworks.com>... > I was wondering if anyone can help me with this > > Have a huge vector of serial date time and i wish to > compute the difference between each element of the vector > with the next element. Basically the pseudo command is > something like this > > find(diff(serial_Time_vector)>1800 seconds) > > I wish to find the index numbers in the vector where the > difference is greater than 30 minutes. Whats the quickest > way to do this? > > Thanks > > Karan Karan, I can't think of a better solution than your code... and it should be quite fast even for a very large time vector. I guess your problem has to do with the fact that you have a "serial date time" vector rather than a sequential time vector in seconds. If that is the case, search for "time series" in the online help. It looks like the function DATENUM can help.
From: Karan on 1 Sep 2007 13:12 Lorenzo The only issue is that my code doesnt work. find(diff(datevec(serial_Time_vector))>1800) is also something that wont work because datevec returns vector as the date time. Now I could send the datevec(serial_Time_vector) into a separate function that could change the vector into a format that i might like i.e seconds, minutes etc i.e. time_in_seconds = convert_time(datevec (serial_Time_vector),'seconds') to return the serial time vector as seconds. Hence the overall function shall look like: find(diff(time_in_seconds)>1800) The only issue now remains is that to get that serial time changed to a vector (using datevec) and then to seconds (by presumably using a for loop to go through each element of the datevec returned value) is going to take agesss!! Unless someone out there has a faster code to do something like this? Cheers Karan "Lorenzo " <lorenz4matlab(a)gmail.com> wrote in message <fbc4ng$gjh$1(a)fred.mathworks.com>... > "Karan " <ksumbaly(a)hotmail.com> wrote in message > <fbc1rh$6n$1(a)fred.mathworks.com>... > > I was wondering if anyone can help me with this > > > > Have a huge vector of serial date time and i wish to > > compute the difference between each element of the vector > > with the next element. Basically the pseudo command is > > something like this > > > > find(diff(serial_Time_vector)>1800 seconds) > > > > I wish to find the index numbers in the vector where the > > difference is greater than 30 minutes. Whats the quickest > > way to do this? > > > > Thanks > > > > Karan > > Karan, > I can't think of a better solution than your code... and it should be quite fast > even for a very large time vector. > I guess your problem has to do with the fact that you have a "serial date time" > vector rather than a sequential time vector in seconds. If that is the case, > search for "time series" in the online help. It looks like the function DATENUM > can help.
From: Karan on 1 Sep 2007 13:48 ok lorenzo the best i could do was vec = round(datevec(sorted_data.Time)); dec_time = vec(:,6)+vec(:,5)*60+vec(:,4)*3600+vec(:,3) *24*3600; index_gt_30mins =find(diff(dec_time)>time_difference); assuming that in the diff(dec_time) we dont get a vector scenario of this sort [ 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 1 ] then the code above fails.... "Lorenzo " <lorenz4matlab(a)gmail.com> wrote in message <fbc4ng$gjh$1(a)fred.mathworks.com>... > "Karan " <ksumbaly(a)hotmail.com> wrote in message > <fbc1rh$6n$1(a)fred.mathworks.com>... > > I was wondering if anyone can help me with this > > > > Have a huge vector of serial date time and i wish to > > compute the difference between each element of the vector > > with the next element. Basically the pseudo command is > > something like this > > > > find(diff(serial_Time_vector)>1800 seconds) > > > > I wish to find the index numbers in the vector where the > > difference is greater than 30 minutes. Whats the quickest > > way to do this? > > > > Thanks > > > > Karan > > Karan, > I can't think of a better solution than your code... and it should be quite fast > even for a very large time vector. > I guess your problem has to do with the fact that you have a "serial date time" > vector rather than a sequential time vector in seconds. If that is the case, > search for "time series" in the online help. It looks like the function DATENUM > can help.
From: Lorenzo on 1 Sep 2007 14:03
Can you post (part of) your initial data? |