LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

delete contents of array?

Hi! I have two arrays, and a waveform graph that is plotted from the two arrays (one x, the other y). I am trying to give the user the ability to complete erase all data and restart the graphing process. I am planning to do this by completely deleting all content from both arrays and then setting the value of the graph to 0. I was wondering how to do this (the array part)? Thanks in advance for any help!

0 Kudos
Message 1 of 6
(2,701 Views)

Perhaps, teach your users how to use the Right Mouse ButtonSmiley Surprised

Capture.PNG

That would be SO much easier than creating a brand new method to do what already exists


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 6
(2,697 Views)

How are you storing your arrays?  If in shift registers, it is just a matter of writing empty arrays to the shift register.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 6
(2,691 Views)

Graphs are just indicators. All you need to do is feed them with new and different data, e.g. an empty array or an array of all zeroes. (Only charts retain data internally and you need to clear the history if needed)

 

The details depend on your code architecture. Can you show us a simplified version of your code?

0 Kudos
Message 4 of 6
(2,674 Views)

The arrays are populated by adding a new coordinate pair (new single value at last index in each array). This process of adding a single value is repeated by a while loop. The graphs merely plot the arrays. As soon as the arrays change, the graph changes. I am trying to click a button called "Clear Data" that will empty an array, thereby allowing new data to fill the arrays and the graph. Data is continuously being uploaded, so I cannot easily change all of the values of the array. An immediate clear (such as the right click, "empty array" feature) would be ideal. I would prefer a programmatic solution however, as opposed to requiring the user to right click (also once the arrays are emptied by this method, they do not repopulate - probably something to do with initializing the arrays but w/e). Any help is appreciated...

0 Kudos
Message 5 of 6
(2,626 Views)

You really need to show us the code.

 

Generally, to "clear" an array you just connect an empty array constant of the same data type to the wire. This can  be done with a case structure or a Select node.

 

Building an array in a while loop can lead to memory allocation problems and slow performance. It is often better to initialize the array outside the loop. Connect the initialized array to the left terminal of a shift register. Inside the loop use Replace Array Subset to update the values in the array. When you want to clear the array connect to the initialized value again. If the array is only used for display purposes, initializing the array with NaN values will have the graph only showing the data which has been replaced. NaNs do not appear on graphs. If you are doing other types of processing on the arrays, some other value such as zero might be better.

 

Lynn

0 Kudos
Message 6 of 6
(2,610 Views)