LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

help putting 480 integers in a 1d array

Hi all
I'm using, thanking to your quickly and detailed answers,labview from some
days,
in my Vi I've noe a little trouble,
I have, in a for structure, 480 integers that came up from a formula
internal in this for,
how can I buold a 1d array of dimension 1*480 with all this numbers,
starting from "zero"?!

In other words do I need to initialize this array? (for example an array
1*480 filled with zeros),
or I could build it simply appending each number to the previous one and the
array will be every time
increased of a unit in terms of dimension?

Thanks a lot to all.

Best regards
0 Kudos
Message 1 of 3
(2,731 Views)
Hi,

If you use "auto indexing", the for loop automatically builds an array.
(Auto indexing is default, when you wire something to a for loop. Right
click the connection dot, to turn it off.) Simply connect the output of the
formula to the for loop, and select Create Indicator (right mouse click).
You will have a new array on the front panel.

If the routine has to be really fast, you can initialize the array, and
replace the element number "i" with the current value. You do need to use a
shift register for the array.

Regards,

Wiebe.


"Sonic" wrote in message
news:Fkkba.38829$pG1.937735@news1.tin.it...
> Hi all
> I'm using, thanking to your quickly and detailed answers,labview from some
> days,
> in my Vi I've noe a little troubl
e,
> I have, in a for structure, 480 integers that came up from a formula
> internal in this for,
> how can I buold a 1d array of dimension 1*480 with all this numbers,
> starting from "zero"?!
>
> In other words do I need to initialize this array? (for example an array
> 1*480 filled with zeros),
> or I could build it simply appending each number to the previous one and
the
> array will be every time
> increased of a unit in terms of dimension?
>
> Thanks a lot to all.
>
> Best regards
>
>
>
0 Kudos
Message 2 of 3
(2,731 Views)
Here's an example with three ways of building arrays using a For loop.
1. Use Replace Array Subset to modify contents of an existing array. This is the most efficient method on older versions of LabView, since the array size is fixed.
2. Use the auto-index feature of the For loop. This is the easiest way to build an array: just wire the integer out of the loop and the loop automatically creates an array. In LabView 6.x, this method is also efficient, since the compiler now looks at the number of iterations in the loop and reserves a chunk of memory big enough for the entire array.
3. Use the Build Array function to add a new element to array each time through the loop, starting with an empty array. This method is the most flexible, since the array size can
be determined at run time. The Build Array function can be placed in a case if you don't want to add elements on every loop iteration. This method is the least efficient: the compiler doesn't know how big the array is at compile time: at run time, it may keep growing in memory so blocks of memory may need to be moved many times to keep the array contiguous.
0 Kudos
Message 3 of 3
(2,731 Views)