LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get corresponding row index of array to plot graph

Solved!
Go to solution

Hi all,

 

so I'm trying to read data from a text file, and plot them onto an XY graph.

 

The string text data file is built as such:

 

XXX;Time/Date Stamp;Data point type A;1;X

XXX;Time/Date Stamp;Data point type B;2;X

XXX;Time/Date Stamp;Data point type C;3;X

XXX;Time/Date Stamp;Data point type A;1;X

XXX;Time/Date Stamp;Data point type B;2;X

. . .

Say I want to plot only point A with the corresponding time stamp, and the data points are distinguished from each other through a number after the semicolon, in this case 1. And if I want the graph for point B I would match with 2 and so on.

 

How do I get the indexes of all the corresponding row that matches with 1 so that I am able to extract them along with the time stamp to plot the graph for data point A? 

 

I attached a snippet of the simplified version of what I have so far and it's not quite right because I'm not getting the correct plot.

 

Thank you in advance!

 

 

0 Kudos
Message 1 of 6
(2,336 Views)
Solution
Accepted by topic author nikvl

Hi nikvl,

 

after creating the arrays for timestamps and "data point" you also should create an array of "position".

Then feed all 3 arrays into a FOR loop containing a simple comparison with desired "position" value. Then use conditional output tunnels to create filtered arrays of timestamp and "data points"…

 

Example:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(2,329 Views)

I had to tweak some things and add an extra for loop but it worked wonderfully. Thanks!

 

Unrelated, but is there a way to make the array of time stamps into seconds starting from 0? (or should I open a new thread for that?)

0 Kudos
Message 3 of 6
(2,281 Views)

Hi nikvl,

 


@nikvl wrote:

Unrelated, but is there a way to make the array of time stamps into seconds starting from 0?


Simple math:

Relative time := absolute time - start time

So just subtract start time from your timestamp array…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 6
(2,280 Views)

I figured, but it skewed the display and the year became 1904. Maybe I'm not setting the start time properly since I used an index array with index 0 (when the index should be at what row the desired data point first appears) 

 

If possible, I'd like to display in seconds without the year like 0, 1 , 2, ....

0 Kudos
Message 5 of 6
(2,271 Views)
Solution
Accepted by topic author nikvl

Hi nikvl,

 

set the format to relative time…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 6
(2,266 Views)