Sign in to follow this  
Guest david allen

Array index by time

Recommended Posts

Guest david allen

Is there a way to determine the array index of a designated time? i.e. I want the value Min ( MyChannel[0, Var.Ndx]) where Var.Ndx is the array index for the data point nearest 22:05:32.


Share this post

Link to post
Share on other sites

You could do this with a little bit of code in a sequence.

Var.i = 0
Var.array_length = NumRows(MyChannel)
while (Var.i < Var.array_length)
   Var.strtimestring = FormatDateTime("%H %M %S", MyChannel.Time[Var.i])
   if (Var.strtimestring == "22 05 32")
	  Var.index = Var.i

This code assumes data was taken once a second, so that a point was recorded on 22:05:32. Really this code would work better if you are reading your data faster than once a second so that you guarantee a point falling inbetween 22:05:32 and 22:05:33. This code also assumes that the array is static and that no new data is coming into the array at the moment.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this