ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I position a graph cursor via code?

I am trying to position a waveform graph cursor based on values obtained from other cursors, that is, I know what the Y value is and I want to find the corresponding X value in order to position that cursor on the graph
0 Kudos
Message 1 of 5
(3,039 Views)
try this example. Hope this helps.
BJD1613

Lead Test Tools Development Engineer

Philips Respironics

Certified LV Architect / Instructor
0 Kudos
Message 2 of 5
(3,039 Views)
you can also read this property to get your x and y values.
BJD1613

Lead Test Tools Development Engineer

Philips Respironics

Certified LV Architect / Instructor
0 Kudos
Message 3 of 5
(3,039 Views)
First, you have to search for the index number of the Y value. This can be a (relatively) tricky operation if the value is just approximate, and if the Y values do not vary monotonously.
In the simplest case (Y data organized in increasing order), what you have to do is
1/ use the threshold 1D array (in the array subpalette), passing the Y values array and the target Y value as input. The node returns the fractionnal X index. If you need to position the cursor exactly on a data point, round the index value to the nearest integer value.
2/ Move the cursor to the corresponding position using the cursor.index property node

If the Y values are continuously decreasing, reverse the array, then go to step 1.

If the Y values do not vary monotonously, then you
are stuck, and you will be obliged to develop a more elaborate algorithm. Accordingly, your next post to this forum will be :
"How can I find a given value in a 1D array ?"

CC
Chilly Charly    (aka CC)
0 Kudos
Message 4 of 5
(3,039 Views)
I just forgot to say that if the Y value is known without uncertainity, the corresponding index value is found using the search 1D array function (also in the Array subpalette). In this case, the Y array does not need to be ordered.
CC
Chilly Charly    (aka CC)
0 Kudos
Message 5 of 5
(3,039 Views)