LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Incrementally adding rows to an array

Greetings,
 
In the attached vi, I would to add a row to an array each time the vi runs to count the number of intervals it take to reach a specified limit.
 
If I specify a limit of 30 and run the vi, I may count 6 intervals, the interval count goes to row 1 of my array.
 
I restart the vi, specifying a limit of 40, I may count 10 intervals, this interval count goes to row 2 of my array.
 
I restart the vi, specifying a limit of 50, I may count 15 intervals, this interval count goes to row 3 of my array and so on for x number of trials
 
I haven't been able to find any examples or previous postings that can help with my requirements.
 
Thanks for your help!
 
 
0 Kudos
Message 1 of 10
(3,613 Views)
Hi!
   I'm not sure I understood your requirements.... but I suppose the use of "insert into array" can be useful to you....

   Have a nice day!

graziano
0 Kudos
Message 2 of 10
(3,601 Views)

Greetings!

If you run the vi I attached, it might clarify what I am asking for in my previous post

For now through an assortment of various trials, I have only been able change the value in the array rather than incrementally adding to the array (as shown it the attached vi).

I have tried in using "insert into array" but am not sure how to specify the index to incrementally add to the array.

I hope this explanation helps.

Thanks for your help!

0 Kudos
Message 3 of 10
(3,594 Views)
Hmm, if I understand your question, you want a 2D array. Like Graziano said, you will want to use Insert into array. Store what iteration you are in (this shouldnt be hard, since it sounds like you are looping), and insert the data points into the 2D array. Do you know the max number of data points you can have in any given row? / do you know the number of iterations beforehand? Because then it will be better to initialize your 2D array beforehand to the max size. Otherwise you will have to frequently resize your array, which is very innefficient. If you initialize the array beforehand, you can use the Replace Array Subset.vi to insert your data points into each row.
 
Also, Labview wont let you have different rows of different lengths in a 2D array, so it pads the end of each array until they are the same length. There are a couple ways of dealing with this:
1) Pad the arrays yourself with some sort of 'tombstone' number, which you know will never occur in the real data (that way you can seperate the real data from the padding)
2) Keep a parallel integer array that stores the number of data points in each row, and use that when accessing the data (so you ignore the padded values).
 
Hopefully this helps


Message Edited by jrpe on 11-09-2007 09:12 AM
Jeff


Using Labview 7 Express
0 Kudos
Message 4 of 10
(3,588 Views)
Hi newbie,

for adding values to an array you should use the "build array" node - it's made just for this purpose!
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 10
(3,585 Views)
I think you need an uninitialized shift register to store your accumulated appended array of Interval Counts. This is not higly efficient if the array may get large, but it may get you started.

I don't think you need the sequence structures. Let the dataflow be your guide.

Lynn
0 Kudos
Message 6 of 10
(3,583 Views)
Hi!

   I've opened your VI, but not on my PC (I have 7.1 LabView).  I used a test PC with a LV 8.2.
 
   I think you're trying to add elements to array, so "insert into array" is what you need.

   Look to attached VI, it can be quite silly, but I hope it gives you an idea!

   Have a nice day!

graziano
0 Kudos
Message 7 of 10
(3,581 Views)
Hi all!

   when I began writing, there was only my post and author's ones..... so I'm late.

   Just to complete my answer, I only want to show a way for appending elements.  Anyway, I don't encourage using it, usually I prefere (when possible) to build fixed size arrays, and handle array last element positioning with a pointer to location.  Thisi is to avoid that for some ununderstood mechanism, to have RAM usage slowly increasing after some time your application is running.

   Of course, I'm influenced by RealTime techniques, and 24h/7days system developement, where memory leaks and similar are quite a bad thing!

  Bye!

graziano
0 Kudos
Message 8 of 10
(3,575 Views)

Greetings!

 

Thank you! Your solution works very well!! This is the BEST user forum easily.

The next step in my vi is to decrement the random number generator multiplier (currently the constant 10) by 1 after each run. I think using your solution of shift registers and the case structure might accomplish this.

Any thoughts?

0 Kudos
Message 9 of 10
(3,567 Views)
Johnsold's posting and attached .vi was the solution to my posting. This software does some incredible stuff. Hopefully I get to use it full time once I get some (lots) of practical experience and confidence. All of the postings were helpful.
 
Newbie 2
0 Kudos
Message 10 of 10
(3,561 Views)