取消
显示结果 
搜索替代 
您的意思是: 

Add Columns of Array

已解决!
转到解答
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 项奖励
1 条消息(共 47 条)
5,959 次查看

This might help you out

0 项奖励
2 条消息(共 47 条)
5,945 次查看

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

Please attach your code.

0 项奖励
3 条消息(共 47 条)
5,940 次查看

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 项奖励
4 条消息(共 47 条)
5,898 次查看

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."

5 条消息(共 47 条)
5,892 次查看

@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 😉

6 条消息(共 47 条)
5,889 次查看
解答
已被主题作者 ap8888 接受

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

easier.png

 

 


"Should be" isn't "Is" -Jay
7 条消息(共 47 条)
5,867 次查看

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

 

Thanks

下载全部
0 项奖励
8 条消息(共 47 条)
5,837 次查看

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
9 条消息(共 47 条)
5,820 次查看

Hi

 

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

Could some one help?

0 项奖励
10 条消息(共 47 条)
5,547 次查看