LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Replacing several Elements in an array with known index

Solved!
Go to solution


Please I would like to know how I can replace a number elements in an Array with zeros where the indexes of the elements to be replaced are built up in an array form too.

0 Kudos
Message 1 of 5
(2,615 Views)
Solution
Accepted by topic author UXE

Use a for loop and replace one element per iteration (keep the data array in a shift register, auto-index the indices to replace).

 

0 Kudos
Message 2 of 5
(2,614 Views)

Thanks,

It worked

0 Kudos
Message 3 of 5
(2,610 Views)

Thanks, It worked but I am have an issue? the index I used was obtained from an array with elements repeating themselves in some cases. for example, the element at Index 0, say 4.75 occured about 20 times in the array so that when I tried getting out the indexes using search 1D array vi it indexed all 20 elements as index 0 (i.e. the index of the first occurence of the repeated elements). Please How do I avoid this?

0 Kudos
Message 4 of 5
(2,599 Views)

You can tell "search 1D array" to start the search at a specific index.

See topmost code in snippet.

If you only want to eliminate specific values you can also avoid the loop by comparing the value (see code in the middle).

But be careful when using search 1D array for floating point numbers. Probably in range & coerce should be used (see bottom code).

 

array-elem-0.png

0 Kudos
Message 5 of 5
(2,592 Views)