From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
03-05-2009 08:30 PM - edited 03-05-2009 08:34 PM
Hi, I am fairly new to Labview.
I have an 2D array..
I want to be able to search for column 0 for all values in the array.
If column 0 return values that are the same in previous row, then use the last row.
I'll attach a picture with this so that it will be easier to understand..
From column 0:
500000 . . . . .
500000 . . . . .
464534 . . . . .
500000 . . . . .
438251 . . . . .
545641 . . . . .
438251 . . . . .
There are 2 values of "438251" in that array for column 0.
There are 3 values of "500000" in that array for column 0.
What can I do to replace the array with something like this..
Want to see in the array
464534 . . . . .
500000 . . . . .
545641 . . . . .
438251 . . . . .
I need to keep all values in the row that is last the same. I have to delete the whole row values that have same value in column 0.
Can someone point me to the right direction with this..Thanks in Advance!
Solved! Go to Solution.
03-05-2009 09:25 PM
I would probably flip the array top to bottom so that I could work from the bottom up.
Now that is is flipped. Keep the first row.
Take the 2nd row, search up to that point. If it doesn't exist append that to the array. If it did exist, just skip it.
Go on to the 3rd, repeat.
So on until you reach the end of the row.
When you are done, flip the array top to bottom.
All this could probably be done with only 1 loop.
Other alternatives would be to use the delete from array function to delete the duplicate row when you find it.
03-06-2009 05:12 AM - edited 03-06-2009 05:13 AM
Just to add to Raven Fan's reply, OpenG has a Remove Duplicates From 1D Array function that does this for you. As he mentioned, you'll need to flip the array to keep the last instance of the duplicated elements. Reverse it again and Bob's your uncle.
03-06-2009 09:19 AM - edited 03-06-2009 09:26 AM
I would probably flip the array top to bottom so that I could work from the bottom up.
Other alternatives would be to use the delete from array function to delete the duplicate row when you find it.
Thanks for the advices. It may sound like a dumb question, but how would I flip the array? i saw reverse1D array...
but i am working with 2d array right?
03-06-2009 09:22 AM
03-06-2009 09:27 AM
i am using labview 7.0 right now.
i think the solution you gave needs 8.6 and higher.
03-06-2009 09:29 AM
you might not see the vi that i have attached with the question.
i started and didnt know how to finish it..
03-06-2009 09:49 AM - edited 03-06-2009 09:51 AM
i think this works...
except for one thing..
i didnt flip it first....
and after the loop...flip it back..
i have to know how to flip the array that ihave first.how would i do that?
03-06-2009 10:00 AM - edited 03-06-2009 10:02 AM
Try this.
Note. The idea I gave above was just one way to do it. You could also do things such as search from the bottom up. It's just a matter of how you loop through the array and how you set your indices for starting and stopping searches. With other methods, it may not be necessary to flip the array.
03-06-2009 10:24 AM
ok...that works...
thanks guys...
my code looks like a mess for doing something like this though...