LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Add Columns of Array

Solved!
Go to solution
I'm having somewhat of an elementary problem here...

I start with a 1D Waveform from a DAQ request, which contains ~22 columns of data corresponding to different measurements. I wanted to take the first 20 columns of this data and add the "column vectors" (i.e. each measurement) to get a 1D array (the summation of the first 22 1D arrays/measurements/vectors). The logical way to do this, it seems, is by indexing the waveform with a for loop, converting to DBL, and then adding each column with a shift register.

1D Waveform --> For loop (indexed) --> Get Waveform Components to get DBL Array for the index column --> Go to "add" block

And then by using a shift register I add each index column.

However, I get no output once the for loop finishes.

Any ideas? Examples are JPEGs/PNGs please!

0 Kudos
Message 1 of 47
(4,643 Views)

This might help you out

0 Kudos
Message 2 of 47
(4,629 Views)

@ap8888 wrote:
However, I get no output once the for loop finishes.

Please attach your code.

0 Kudos
Message 3 of 47
(4,624 Views)

Thank you both for the help.

 

I always thought an indexer of a for loop indexes columns, not rows. But in Fernando's example it seems like rows are being index, then summed.

 

Why, for example, is the attached not working?

0 Kudos
Message 4 of 47
(4,582 Views)

array a = [1,2,3]

array b = [1,2,3,4,5]

 

in LV a+b = [2,4,6].

 

In your case you are adding [] to [n, n+1, n+2]. You cannot do this.

 

In this situation, you should have used the "build array" function, right clicked it, and selected "concatenate inputs."

Message 5 of 47
(4,576 Views)

@Fernando0901 wrote:

 

In your case you are adding [] to [n, n+1, n+2]. You cannot do this.

 

 



You can do this, it just wont work the way you want 😉

Message 6 of 47
(4,573 Views)
Solution
Accepted by ap8888

I'm a big fan of doing things the easy way.

easier.png

 

 


"Should be" isn't "Is" -Jay
Message 7 of 47
(4,551 Views)

So to verify, the attached two blocks perform the exact same summing (of columns) operation?

 

Thanks

Download All
0 Kudos
Message 8 of 47
(4,521 Views)

Summed would have the same result in either case- Which is quicker to sling?  What if you wanted to really boost the array size and started bogging down a CPU core?  Which for loop is parallelizable?

 

One.jpg on all counts.

 

Now wait for Altenbach,  He'll chime in with a perfomance enhancement

 

Hold it..... I'm channelling.

 

For even better perfomance, since the size of the output array can be determined.  Initiallize an array of the required size and replace index[i] inside the loop.  This prevents re-allocating the array buffer multiple times as the array size grows"


"Should be" isn't "Is" -Jay
Message 9 of 47
(4,504 Views)

Hi

 

I try to find the number of ones in array at the end but it is not working.

Could some one help?

0 Kudos
Message 10 of 47
(4,231 Views)