# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Select data between cursors on a graph

Hi,

For my project, I'd like to select data between cursors on a graph and export them to an Excel file.

To achieve this, I'm using property nodes for the cursors.

I want to use a case structure to build an array from the data that falls between the cursors.

However, I can't connect the boolean result from the comparisons to the case structure.

Any ideas?

Thanks!

Message 1 of 25
(3,384 Views)

## Re: Select data between cursors on a graph

@Alexb91  a écrit :

I can't connect the boolean result from the comparisons to the case structure.

Any ideas?

Hi Alex,

Output of your AND function is an array of booleans.

Input for the case structure is boolean.

Message 2 of 25
(3,372 Views)
Solution
Accepted by Alexb91

## Re: Select data between cursors on a graph

I assume you want two different x positions, not an x and a y position, right, so why are you reading the y position?

If you would uses cursors that are locked to the plot, you can use "cursor index" and get the array subset based on the positions. No FOR loop needed!

(simple old example here, but there are many others)

Message 3 of 25
(3,338 Views)

## Re: Select data between cursors on a graph

Interesting.

The problem is I have multiple plots shown on the graph.

Could this still work?

Message 4 of 25
(3,324 Views)

## Re: Select data between cursors on a graph

Thanks i’ll try it out!

Message 5 of 25
(3,322 Views)

## Re: Select data between cursors on a graph

Correct, I just want two x positions.

My idea is to store the data between the cursors in an array during each iteration. Then, I want to write this data to an Excel file.

I'd like to have a "write to Excel" button so that each time I press this button, it starts an iteration.

Ideally, this would be outside the while loop, so that I extract the data when all the measurements are finished and the while loop is stopped.

Do you have any ideas on how I could achieve this?

Message 6 of 25
(3,290 Views)

## Re: Select data between cursors on a graph

@Alexb91 wrote:

I'd like to have a "write to Excel" button so that each time I press this button, it starts an iteration.

Ideally, this would be outside the while loop, so that I extract the data when all the measurements are finished and the while loop is stopped.

You have contradictory and silly requirements. That don't make a lot of sense

Writing to excel is not the same as starting an iteration, so please clarify what should happen.

Your toplevel program architecture should be a simple state machine, where writing the subset to file, staring a new acquisition, do nothing, and everything else is just a state. Nothing should ever be outside the toplevel loop (except maybe initialization and cleanup code).

Message 7 of 25
(3,245 Views)

## Re: Select data between cursors on a graph

@altenbach wrote:

(simple old example here, but there are many others)

i remember the original post 😄

Message 8 of 25
(3,206 Views)

## Re: Select data between cursors on a graph

Sorry, I'll try to be clearer about what I'm trying to achieve.

Basically, at the end of the data acquisition, I want to select data between cursors.

Then, I want to have a button that prints said data into Excel file.

I want to create a different file each time I press the button.

For example:

• File 1 = data from 1 am to 3 am
• File 2 = data from 4 am to 6 am

I want to perform this operation outside of the while loop because I want to do it when the data acquisition is stopped.

Message 9 of 25
(3,183 Views)

## Re: Select data between cursors on a graph

@Alexb91 wrote:

I want to perform this operation outside of the while loop because I want to do it when the data acquisition is stopped.

It is clear what you want. As I already said, no interactive code should ever be outside the toplevel loop. All you need is a state machine where one state is recording data at regular intervals, and one state is idle (no recording or waiting for an elapsed time before recording the next datapoints) and a state for saving. If it is outside the loop, you can only save one set unless you place yet another loop for repeated saving. It is silly to have multiple consecutive loop if you really only need exactly one! Done right, you can even select and save a selection while it is still recording new data.

If the recording should be fast, it can be in a parallel while loop communicating with the UI loop via queues, for example. Your recording seems to be quite slow, so a little jitter due to saving is probably irrelevant.

Message 10 of 25
(3,170 Views)