LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Filling array with indexes of non-zero elements

Solved!
Go to solution

Hello,

 

Applying 8 digital waveforms, I'm trying to create 8 arrays of index where bit = '1'.

For simplicity in the code below I process only 7-th (last waveform).

The lenght of array should be less than waveform length , because the number of '1' is less than waveform length.

The output is a little bit strange.

If i-th bit is '1', its index is added to array ... it's OK.

But what is wrong - if i-th bit is '0', nothing must be added to array, but in my case 0 value is added.

Thanks in advance.

Pavel.

 

0 Kudos
Message 1 of 3
(2,268 Views)
Solution
Accepted by topic author Pavel_147

Firstly, you can use conditional tunnels.

Secondly, LabVIEW does not allow ragged 2D arrays where different rows have different lengths, so things will get padded at the outer loop again.

If you want ragged arrays, insert a "bundle" before the outer indexing output. You'll get a 1D array where each element is a cluster containing a 1D array of variable length.

 

If you would present the digital waveform as integers, all you need is a simple masking operation to see if a certain bit is set.

Message 2 of 3
(2,263 Views)

Works nice with conditional tunnels.

Thanks.

 

 

0 Kudos
Message 3 of 3
(2,221 Views)