LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with Array

Happy Thanksgiving everyone. I have a simple yet complicated problem.

 

 I have an empty array of one dimension . I also have a numeric control. Whenever the user adjust the control say to 3, the number of elements available in the array should be 3. Then the user can now input the values he wants in the array.

 

so if the user adjusts the numeric control to say 7, there should be 7 elements available in the array. then the user can now enter  seven values in the array.

 

Thanks

 

 

 

0 Kudos
Message 1 of 4
(2,998 Views)

ade,

 

It seems like an event driven array redim type operation.  I would put an event structure on your block diagram and construct a resized array on the value change event of your numeric control.  I attached a vi that will resize and preserve the contents.  It is a bit simpler problem if you don't need to keep the current contents of the array when it is resized.  This works for a 1D array, but could probably be extended for a 2D.  (LabVIEW 8.5)

 

Cheers

-cb

Download All
0 Kudos
Message 2 of 4
(2,989 Views)

You can use reshape array to pad or trim a 1D array to a new length. Try it. 🙂

 

Since this is a control, you would need to write the new data to the control via a local varaible, for example.

 

In addition, you might want to hide the array index display and change the number of visible elements on the front panel via a property node. Otherwise, the user could easily click on an element outside the desired size and thus increase it beyond the intent of the programmer. (remember, the number of visible elements is completey unrelated to the array size).

 

Further details depend on the rest of your code. If you give us more details (or attach your program) we might be able to give more specific advice. 🙂

0 Kudos
Message 3 of 4
(2,988 Views)

Here's a quick example (LV 8.0). See if it makes sense.

 

 

 

 

Message Edited by altenbach on 11-26-2008 03:13 PM
Download All
0 Kudos
Message 4 of 4
(2,970 Views)