Array index by time


Guest david allen

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.

da

Link to comment
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
	  break
   endif
   Var.i++
endwhile

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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.