07-10-2014 09:43 PM
Hi all,
I have a very simple question. If I get data from a while loop. (1 point each loop, e.g. 11, 12, 11, 12, 23 at the first 5 loops). How can I make an array of this? I always get one data at the first loop.
07-10-2014 09:48 PM - edited 07-10-2014 09:48 PM
Use a shift register initialized with a 1D array and use build array to append the scalar.
07-10-2014 09:51 PM
07-10-2014 11:18 PM
Hi,
Here is the code for solutions suggested by Christian and Dennis.
In Dennis's solution you will get array after stoping while loop. But in Christian solution you are able to see array if while loop in tunning also.
07-11-2014 01:30 PM
The solutions posted work, but again realize that if you run for a long time memory will continue to increase. You do not have unlimited resources and building an array of an unbounded size will result is no available memory eventually.
It would be best to make sure the array size doesn't grow beyond some value. If you use the build array method you can look at array size, and if it is greater than some value, perform an array subset and get the last X number of points. That is unless you truely need all values at which point you would need to think about File I/O or other methods of temporarily storing the array. Of course if you know your while loop won't run more than some value you probably don't need to worry about it.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
07-11-2014 02:43 PM
@Hooovahh wrote:
The solutions posted work, but again realize that if you run for a long time memory will continue to increase. You do not have unlimited resources and building an array of an unbounded size will result is no available memory eventually.
It would be best to make sure the array size doesn't grow beyond some value. If you use the build array method you can look at array size, and if it is greater than some value, perform an array subset and get the last X number of points. That is unless you truely need all values at which point you would need to think about File I/O or other methods of temporarily storing the array. Of course if you know your while loop won't run more than some value you probably don't need to worry about it.
Another method to go along with Hooovahh's concept here is to preallocate an array and store it in the shift register. You then use Replace Array Subset to update the array. You just need to keep track of which element to replace. This avoids the whole reallocation of memory each time you add another element to the array.