LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array Question

Highlighted
I need to set the elements of an array to zero after a certain index ie

for a 1024 point array I want to put all terms from 17 to 1024 to zero
without changing the dimension. Thismustbe easy but I am unsure
which .vi to use. I tried one of them but it reduced thedimension to
16 which is not what I want.

James
0 Kudos
Message 1 of 6
(1,132 Views)
Highlighted
If you already have the 16 element array, reshaping the array to 1024 will fill the rest with zeroes.
Hope this helps
0 Kudos
Message 2 of 6
(1,132 Views)
Highlighted
James,

There are several ways to do this. You can put the vi Replace Element
Array in a for loop (N=1024-17), add 16 to the itterion and connect
the itteration terminal to the Index input of the vi. Connect a constant to
Element Data (zero). Don't forget to use a shift register.

You can also split the array between the 16th and 17th element with Split
Array. Then initialise a new array (1024-17 elements, value =0) and add
it to the First Subarray output of Split Array with Build Array.
0 Kudos
Message 3 of 6
(1,132 Views)
Highlighted
Many thanks

I was thinking along the same lines - I followed all of your first method
except the bit about the shift register - where does it go?
Also is Replace Array Subset what I want? I cannot find Replace Element
Array in Version 6??

Regards

James


Max wrote:

> James,
>
> There are several ways to do this. You can put the vi Replace Element
> Array in a for loop (N=1024-17), add 16 to the itterion and connect
> the itteration terminal to the Index input of the vi. Connect a constant to
> Element Data (zero). Don't forget to use a shift register.
>
> You can also split the array between the 16th and 17th element with Split
> Array. Then initialise a new array (1024-17 elements, value =0) and add
> it to the First Subarray output of Split Array with B
uild Array.
0 Kudos
Message 4 of 6
(1,132 Views)
Highlighted
> I was thinking along the same lines - I followed all of your first method
> except the bit about the shift register - where does it go?
> Also is Replace Array Subset what I want? I cannot find Replace Element
> Array in Version 6??
>

The shift register should be located on the loop that contains the replace
node. If you already have 6i, then you do not have a Replace element
node inside of a loop, replacing an element at a time. You can
replace a subset in one step. Wire up the location for the replace
and then wire up a new array of 1024 - 17 zeroes. You can build this
using the Initialize array function or any other way that you like.

The replace array subset is a great node to know how to use, but for
this case where you want all of the
elements to be the same default value,
do this instead. Take your input array. Reshape it to have only 16 elements.
The reshape it to have 1024 elements.

Greg McKaskle
0 Kudos
Message 5 of 6
(1,132 Views)
Highlighted
Thanks

I got it at last after a few stumbling blocks. I hada complex array and was
setting some
of it to zero using real values instead of converting them to complex

ie

a+j0 not equal to a !!


It accepted it but said there were compile errors when i pressed the button!!!



Greg McKaskle wrote:

> > I was thinking along the same lines - I followed all of your first method
> > except the bit about the shift register - where does it go?
> > Also is Replace Array Subset what I want? I cannot find Replace Element
> > Array in Version 6??
> >
>
> The shift register should be located on the loop that contains the replace
> node. If you already have 6i, then you do not have a Replace element
> node inside of a loop, replacing an element at a t
ime. You can
> replace a subset in one step. Wire up the location for the replace
> and then wire up a new array of 1024 - 17 zeroes. You can build this
> using the Initialize array function or any other way that you like.
>
> The replace array subset is a great node to know how to use, but for
> this case where you want all of the elements to be the same default value,
> do this instead. Take your input array. Reshape it to have only 16 elements.
> The reshape it to have 1024 elements.
>
> Greg McKaskle
0 Kudos
Message 6 of 6
(1,132 Views)