LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to avarage 2D arrays

I want to calculate the summation of all 2D arrys that are produced as long as while loop is running (using **bleep** register) in labview. Then, as the user stops the loop, it calculates the average of those arrys and delivers a 2D array.  I think, I need to define an initialized shift register, so I need to wire a 2D zero array to the shift register, but I dont know how to do this and how to calculate the average.

Thank you in advance,

Regards

0 Kudos
Message 1 of 22
(4,658 Views)

sara14 a écrit :

I want to calculate the summation of all 2D arrys that are produced as long as while loop is running (using **bleep** register) in labview. Then, as the user stops the loop, it calculates the average of those arrys and delivers a 2D array.  I think, I need to define an initialized shift register, so I need to wire a 2D zero array to the shift register, but I dont know how to do this and how to calculate the average.

Thank you in advance,

Regards


Since the output is a 2D array I would guess that you want want an average value for each array position. As you say you need to wire a 2D zero array to the shift register. In the while loop just add the new 2D array to the 2D array from the shift register and send the sum to the loop right shift register. When you exit the loop divide the sum array by the value of the index terminal +1.

 

Ben64

0 Kudos
Message 2 of 22
(4,650 Views)

Hi Ben,

Thanks a lot for yr reply.

I did this but as you can see, the value of matrix after + is always zero.

I have attached the snap shot here

Regards

0 Kudos
Message 3 of 22
(4,638 Views)

Your shift register initially contains an empty array and array operations (e.g. your add primitive) truncate to the smallest array input. Your array will remain size zero. Easiest would be to use a small case structure and feed the 2D array directly to the right shift register on the first iteration. keep the addition in the other case.

 

Of course if the image array is always the same size, you can initialize the shift register with a correctly sized 2D array containing all zeroes before the loop.

Message 4 of 22
(4,618 Views)

Hi altenbach,

Thanks for your advice. 1) I can use shift register only for while/for loop not case structure, so now I am confused! about " use a small case structure and feed the 2D array directly to the right shift register on the first iteration. keep the addition in the other case."

2) I don't know how to create a zero 2D array with the same size and I am not sure if image array is always same

Thanks for your help

Regards

 

0 Kudos
Message 5 of 22
(4,605 Views)

Hi altenbach,

You mean something like this that I have attached here? then I should add it to what?Now I dont know to add it to what? whatever that I do turns to zero.

Thanks

Regards

0 Kudos
Message 6 of 22
(4,579 Views)
The case statement belongs in the main while loop. Wire the iteration terminal (the i) to the case selector.
0 Kudos
Message 7 of 22
(4,556 Views)

Hi Dennis,

I think it dosen't work either, i am confused about proper wiering of + and ouputs of shift register, aswell.

Thanks

Regards

Download All
0 Kudos
Message 8 of 22
(4,464 Views)

Here's what I mean with the case structure. (I did not touch the rest of your code)

 

0 Kudos
Message 9 of 22
(4,449 Views)

Hi altenbach,

Many thanks, it works now. I dont undrestand how this case structre works, I would like to learn. So far, I have used only true/false one.

When I insert the value of N, even after that it accomplishes the loop and gives the out put, it starts the loop again from zero and runs it again.

Thank you so much that you spend time to help

Regards

 

 

 

0 Kudos
Message 10 of 22
(4,436 Views)