06-04-2014 11:47 PM
I have array look like the one below. As you see some of the column only has strings of 1 and some random string. I want to be able to delete those columns that have only 1 from the array and replace exact same column that the one before them has and count the # of repeat. All of the strings and their location will be generated so they won’t be exactly like this for every iteration in loop.
This is what I have:.
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
kjhj |
1 |
1 |
1 |
1 |
1 |
jhj |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
kjfhj |
1 |
1 |
1 |
1 |
1 |
1 |
jshhgy |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
uhuh |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
jhsgdv |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
This is what I want:
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
kjhj |
1 |
1 |
1 |
1 |
1 |
jhj[2] |
jhj[1] |
jhj[0] |
1 |
1 |
1 |
1 |
1 |
kjfhj |
1 |
1 |
1 |
1 |
1 |
1 |
jshhgy[1] |
jshhgy[0] |
1 |
1 |
1 |
1 |
1 |
1 |
uhuh |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
jhsgdv |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
Solved! Go to Solution.
06-05-2014 01:31 AM - edited 06-05-2014 02:19 AM
Try something like this.
(Of course you need to decide what should happen if the first column is all ones.)
06-05-2014 01:32 AM
I am not very clear. On what basis is jhj[0] and jhj[1] getting generated?
06-05-2014 01:48 AM - edited 06-05-2014 01:50 AM
Delete
06-05-2014 02:39 AM
Great job!!!!!!!Looks like it’s working but I still have to connect it to the rest of my labview and make sure it works.
My mistake but would you resend me the code with the iteration of the repeated item backward? Like the one below?
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
kjhj |
1 |
1 |
1 |
1 |
1 |
jhj[0] |
jhj[1] |
jhj[2] |
1 |
1 |
1 |
1 |
1 |
kjfhj |
1 |
1 |
1 |
1 |
1 |
1 |
jshhgy[0] |
jshhgy[1] |
1 |
1 |
1 |
1 |
1 |
1 |
uhuh |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
jhsgdv |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
06-05-2014 02:48 AM
I am so sorry i mean to say this
1 |
1 |
1 |
1 |
1 |
1 |
Kjhj[2] |
Kjhj[1] |
Kjhj[0] |
1 |
1 |
1 |
1 |
1 |
jhj |
1 |
1 |
1 |
1 |
1 |
1 |
Kjfhj[0] |
Kjfhj[1] |
1 |
1 |
1 |
1 |
1 |
1 |
jshhgy[0] |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
uhuh |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
jhsgdv |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
06-05-2014 09:04 AM - edited 06-05-2014 09:11 AM
@razii wrote:
Great job!!!!!!!Looks like it’s working but I still have to connect it to the rest of my labview and make sure it works.
My mistake but would you resend me the code with the iteration of the repeated item backward? Like the one below?
That's actually a much easier problem! Give me a few minutes....
(In the simplest case, we ca just remove the two "reverse array" operations, but further simplications are possible (not shown)).
06-05-2014 01:15 PM
Thank you but there is a part that you missed and that's probably my fault. You catch the fact that I wanted the increment to reverse (good job) but you did not pay attention that I was also asking you to increment the item after not the one before. If you compare my second chart I sent, you will see what I am talking about. Is there any way you can fix it and send it again? Thanks
06-05-2014 01:29 PM - edited 06-05-2014 01:38 PM
Well, you got all the templates right there. It is trivial to change, simply process the 2D array starting with the last column. 😉 Try it!
06-05-2014 01:36 PM - edited 06-05-2014 01:37 PM
Here is my 2 minute rewrite based on the older code. Of course i could be simplified coding from scratch, but who cares... 😉
(One difference: It does not put the "jshhgy[0]" in the third column, because that seems like an exception.)