03-06-2009 10:40 AM
Ooooh, you're gonna get some criticism on the forums for that one.
Sequence structures and local variables
03-06-2009 10:49 AM - edited 03-06-2009 10:52 AM
Cory K wrote:Ooooh, you're gonna get some criticism on the forums for that one.
Sequence structures and local variables
Oooh, yep. Definitely needs criticism.
Actually, its not bad and the code is clean.
I would make one recommendation and eliminate the local variable "Array" that was just inside and after the flipping functions. Why? Because you have a data set as an input, and you've effectively changed the dataset appearance on your front panel by writing the flipped array back to the local variable. Keep clicking run and you see your control array flips back and forth and the resulting data changes because you've changed the input data set for the next time the VI is run. The results are based on what the array looked like when the instant the VI started, and not what it looks like when the VI ended.
03-06-2009 10:59 AM
03-06-2009 12:09 PM
actually, I take that back...
it doesn't work completely...
it only work for index 0.
so any duplicates after that..it doesnt look at?
03-06-2009 12:59 PM - edited 03-06-2009 01:03 PM
Try a shift register on your outer while loop as well.
Also, your stop condition is wrong.
You want the loop to stop when the size of the array is less than or equal to i +1. Right now you have it when the array size is greater than i, which it will be right on the first iteration because i=0
03-06-2009 01:13 PM
woww..cool..thanks....
hmmm..i am still surpised it took this many code to do something that small..
maybe OpenG was a better option?
03-06-2009 03:54 PM - edited 03-06-2009 03:59 PM
ok...after i got back from lunch..the program is not looking as disired..
it doesn't delete all rows with duplicates...
it only delete the rows with the first elements that it sees..
I made this change..
i think you had it as...
if N > i (i=1) then stop..
and that causes the while loop to stop and i dont think we want that.
03-06-2009 08:46 PM - edited 03-06-2009 08:47 PM
Giangliang wrote:
I made this change..
i think you had it as...
if N > i (i=1) then stop..
and that causes the while loop to stop and i dont think we want that.
You're right. I got to making the change on the comparison , but I forgot to reverse the inputs on the comparison.
I think I know why there is an issue with some duplicates. I rthink it occurs when there are some consecutive duplicates. It is in the inner For Loop. Let's say you have row 0 (after transposing), and there duplicates on row 3 and 4. It gets to row 3, and deletes it, Now row 4 becomes 3. But then the next instance goes to row 4 (because the calculation is based off the For Loop's i terminal), having completely jumped over the new row 3.
See the attached changes. In the False case is an increment +1 function. So if it finds a duplicate and deletes it from the array, it stays at that row. If it sees it isn't a duplicate, only then does it increment the index.