LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Tricks to populate arrays with data?

Sometimes I want an array of numeric or string values to test out a VI before I have real data to play with, for instance when I want to see if text is going into a spreadsheet where I think it is going. The only thing that comes to mind is to make a loop, wire the index or a random data out, and convert if needed. Then wire to a control's local variable or value property (the arrays I find myself wanting to populate tend to be controls). Run once, then delete or disable the data population.

 

I figured someone has a better way of doing this (it would make a great quick drop shortcut!), please let me know!

0 Kudos
Message 1 of 5
(3,295 Views)

I saw a micro nugget of some sort awhile back (I forget who/where and am too lazy to look for it), on this.

 

 It isn't the most useful for large arrays, but if you want to just fill in one manually, push  CTL-M to go in to "Run Mode".  This will allow you to tab around inside of the array correctly to quickly populate it without needing lots of extra clicks / expanding, etc.  You can then right click on the array and "Create Constant" and just have it chilling on your block diagram ready to be tested with.

Message 2 of 5
(3,287 Views)

Once you have a populated array, you could save it as a control for later use. Perhaps have a library of pre-filled array controls of various types and dimensions. Then you can copy the contents of your pre-filled arrays to the target array (right-click the array control on the front panel, then use Data Operations->Copy/Paste Data).

 

Similarly if you had a VI which randomly generated the desired array type and dimensions, you could do the same copy/paste operation to the target VI, without the need to wire up local variables.




Certified LabVIEW Architect
Unless otherwise stated, all code snippets and examples provided
by me are "as is", and are free to use and modify without attribution.
0 Kudos
Message 3 of 5
(3,252 Views)

I think there are also functions that can generate arrays of white noise / random data in the maths/signal analysis palette.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 4 of 5
(3,207 Views)

@Gregory wrote:

 

...it would make a great quick drop shortcut!


I suggest you do that (or a right click plugin in 2015). It can be a dialog where you select different types of data (1 to N, N random values, values you input yourself in a control which is easier to work with, like a string with multiple rows, etc.) and then write the value to the selected control/constant.


___________________
Try to take over the world!
0 Kudos
Message 5 of 5
(3,171 Views)