From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Finding number of datapoints within time interval

Hello

 

I have a 2D array, with one column for time/date and one for data measurements. I want to specify a upper and a lower time limit, and then be able to find out how many data points that lies within this time interval. Can anyone help me with this?

 

Greetings

Kristoffer

0 Kudos
Message 1 of 13
(2,521 Views)

Hi,

 

What I would do is to find the index where the data enters your range and the index where the data leaves your ranger, then just take a subarray out of the original array starting at the first index and going the length to the next index.

 

The attached vi should be a good template.

 

Regards,

Rob Afton

Message 2 of 13
(2,501 Views)

Hi!

 

Thanks for that, hoping that this can help me a bit further. Just one question, as I am calculating within a loop, and therefore the upper and lower limits will change during the looping. My data consist of both date and time, and i haven't been able to convert this into a timestamp without using the "Scan from string" vi. Any suggestion on how to solve this?:)

 

Greetings

Kristoffer

0 Kudos
Message 3 of 13
(2,497 Views)

Date/Time to Seconds will return the time in seconds.

 

Found on the Timing palette

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 4 of 13
(2,494 Views)

But, to be able to use that, don't I have to convert the time/date colum in the array into seconds also?

 

Greetings

Kristoffer

0 Kudos
Message 5 of 13
(2,489 Views)

Yes.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 13
(2,485 Views)

Ok.

 

So, right now I have a 1D array of type string with time/date. May I ask you the easiest way to go from this and to a 1D array containing seconds?:)

 

Greetings

Kristoffer

0 Kudos
Message 7 of 13
(2,478 Views)

Wire the 1d array of strings conating time and date as a string to a For loop and inside the loop foramt the time date and pass same to the Time-Date to seconds and wire the output of that to the edge of the For loop.

 

LV will automatically index an array on the edge to select each value coming in and will do similar on the output resulting in an array of times in seconds.

 

If you have trouble post an IMAGE of your code so we can advise further.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 13
(2,475 Views)

Wire the 1d array of strings conating time and date as a string to a For loop and inside the loop foramt the time date and pass same to the Time-Date to seconds and wire the output of that to the edge of the For loop.

 

LV will automatically index an array on the edge to select each value coming in and will do similar on the output resulting in an array of times in seconds.

 

If you have trouble post an IMAGE of your code so we can advise further.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 9 of 13
(2,473 Views)

Thanks!

 

I can see how it is supposed to work. I just have one problem, and that is connecting the timestamp output in the for-loop with the time/date converter. I have attached the code, so would be great if you could have a quick look at it.

 

Greetings

Kristoffer

0 Kudos
Message 10 of 13
(2,470 Views)