LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

search 2d array and replace

Solved!
Go to solution

Ooooh, you're gonna get some criticism on the forums for that one.

Sequence structures and local variables Smiley Surprised

Cory K
Message 11 of 18
(1,646 Views)

Cory K wrote:

Ooooh, you're gonna get some criticism on the forums for that one.

Sequence structures and local variables Smiley Surprised


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.

Message Edited by Ravens Fan on 03-06-2009 11:52 AM
Message 12 of 18
(1,643 Views)
thank you guys for the great learning experience!!!!
0 Kudos
Message 13 of 18
(1,634 Views)

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?

0 Kudos
Message 14 of 18
(1,614 Views)
Solution
Accepted by topic author Giangliang

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

Message Edited by Ravens Fan on 03-06-2009 02:03 PM
0 Kudos
Message 15 of 18
(1,604 Views)

woww..cool..thanks....

hmmm..i am still surpised it took this many code to do something that small..

maybe OpenG was a better option?

0 Kudos
Message 16 of 18
(1,593 Views)

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.

 

 

 

Message Edited by Giangliang on 03-06-2009 03:59 PM
Message Edited by Giangliang on 03-06-2009 03:59 PM
0 Kudos
Message 17 of 18
(1,585 Views)

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.

Message Edited by Ravens Fan on 03-06-2009 09:47 PM
0 Kudos
Message 18 of 18
(1,561 Views)