05-31-2012 05:21 PM
Hello all,
Simply put, I am building a program that takes 1D arrays and concatenates them into a 2D array from which I take the mean/mode/etc of each column and represent the result as a single 1D array. I have placed this part of the code in a different VI made a connector terminal and so on. I placed this VI in a state machine and I call it everytime that "state" is activated, when I call the VI for the first time it is quick and responsive (approximately 10 seconds to produce the data), once this is finished the state machine continues in another state and once I call that state again the VI will take 20-30 seconds, if I do this a third time it can take up to 5 minutes to produce the data. Everytime I call the VI i give it identical length arrays and the computations should be very very similar, is it possible that the VI is "holding" the data in its arrays and they're building to be longer and longer every time I call it? If so is there any way to clear all variables and make it start all the arrays from the begining again?
I guess I'm new to data manipulation (most of my work is in hardware configuration), but please if anyone has any advice that's be great!
I can post a demo program if people would like,
Thanks.
Solved! Go to Solution.
05-31-2012 05:25 PM
My guess is you have an uninitialized shift register. Posting an example would definitely help.
05-31-2012 06:48 PM
My main thought is that you are building your array and concatinating onto your previous array. As already stated, it is likely an uninitialized shift register or something of the like. Posting the VI will allow us to debug easier.
06-01-2012 03:43 PM
Phenomenal, thats exactly the issue!! I have wired an "Initialize array" to the shift registers (I had many) and the program runs at its proper speed everytime I execute it.
Thanks both of you very much for your assistance.
06-01-2012 10:50 PM
What is an "initialize array"? Typically you would simply wire an empty array diagram constant. ;).
06-02-2012 12:26 AM
@altenbach wrote:
What is an "initialize array"? Typically you would simply wire an empty array diagram constant. ;).
I think it's safe to assume the poster meant exactly what they wrote, and connected the "initialize array" function to the shift register. With a 0 length, one hopes.
06-02-2012 05:33 AM
Regardless, it resets the array size each time, even if it were to a new 1000 post array. 🙂
/Y
06-14-2012 06:57 AM
This is correct, I attached an "initialize array" vi with a size of 0 to the shift register of the loop. As Yamaeda pointed out, it resets the array for me. I do suppose however, what altenbach is saying would work as well, and likely his solution is more direct and therefore possibly more computationally efficient? just a guess, I haven't checked.
06-14-2012 11:24 AM
@ngio wrote:
This is correct, I attached an "initialize array" vi with a size of 0 to the shift register of the loop. As Yamaeda pointed out, it resets the array for me. I do suppose however, what altenbach is saying would work as well, and likely his solution is more direct and therefore possibly more computationally efficient? just a guess, I haven't checked.
While I'm not completely certain of this, I expect that an empty array constant is equivalent to Initialize Array with a 0 length input, since the initialize array should get folded into a constant during compilation.