03-28-2015 04:17 PM
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
03-28-2015 04:36 PM
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
03-28-2015 06:12 PM
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
03-28-2015 06:36 PM - edited 03-28-2015 06:40 PM
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.
03-28-2015 07:13 PM
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
03-28-2015 09:11 PM
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
03-28-2015 10:14 PM
03-29-2015 11:53 AM
Hi Dennis,
I think it dosen't work either, i am confused about proper wiering of + and ouputs of shift register, aswell.
Thanks
Regards
03-29-2015 12:28 PM
Here's what I mean with the case structure. (I did not touch the rest of your code)
03-29-2015 01:36 PM
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