07-20-2012 05:09 PM
A data was collected once a time in a loop, and appended to a data array. The collection was finished after the loop ends and a data array was built. At the end the data was written to a file. The program was terminated naturally. I assume all the variables are cleared from memory after termination, but it was not. If I run the program twice without close it, I am having a newly collected set of data appended to the old ones, which was created in my last run. A third set was appended if I run it once more.
I just want to keep the latest run as my data and I don't want to close the program to set all my parameters of similar runs. How to do it?
An example file is attached.
Thanks.
Solved! Go to Solution.
07-20-2012 05:21 PM
You need to wire an empty array constant to the initializer terminal (bottom terminal) of the feedback node.
07-20-2012 06:34 PM
Thanks. Pretty new to labview. I was thinking that way too. But I couldn't find such a thing from the function panel. There are alot of things are experience based.
07-20-2012 06:42 PM
Not sure if this is what you mentioned. It didn't work. See attached.
07-20-2012 06:54 PM
@hrwang wrote:
But I couldn't find such a thing from the function panel.
No need to find it. Simply right-click the initializer terminal and select "create constant".
Also:
07-20-2012 06:57 PM
@hrwang wrote:
Not sure if this is what you mentioned. It didn't work. See attached.
The data lives in the feedback node, not in the indicator. Wire the empty array to the bottom of the feedback node. Delete these local variables!
07-20-2012 06:58 PM
It worked. Thanks. Is there anyway to empty the array after the program ends?
07-20-2012 07:09 PM - edited 07-20-2012 07:10 PM
@hrwang wrote:
It worked. Thanks. Is there anyway to empty the array after the program ends?
Why? There is no need to do so. The memory will be release when you close LabVIEW. Also, when you save the VI, the data is not included.
Assuming that your x-vaules are actually not spaced equally (even though they currently are), here's what you could do.
07-23-2012 12:20 PM
There are difference between program is terminated and closed. The memories are released if the program is closed. The variables are not released if the program is stoped and run without being closed. You can try to run the VI attached twice without close it, and check the result of second run.
07-23-2012 12:35 PM
The code was just a demonstration of what I want. I wan to generate a data from a device and put it into an array, modify the array use some math and get an updated array. So I really need the array in the loop and get graph updated at each loop step.
Thanks for instructions.