LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to remove all blank spaces and 0's from 2D array

Solved!
Go to solution

I am trying to remove the blank spaces from a 2D array. I break it down using 2 for loops but I am not getting any data back. The shift register should carry the data through?

0 Kudos
Message 1 of 5
(3,316 Views)

Hi LearningLabVIEW,

 

The middle For Loop isn't actually doing anything because you're trying to index an empty 2D array constant (if you run with highlight execution on, you can see it). A quick fix is to instead replace your empty 2D string array with an array of zeros (or empty strings, or anything, actually) that's the same dimension as your Data Array.

 

And since you're using a Build Array function, it'll end up removing all the zeroes/blank spaces from Data Array, but it will also just append the result it to the end of your "source" array...you could just delete the first three columns afterwards (again, quick fix).

 

I'm sure someone else will chime in a better way to do it, that's just what I noticed in the two minutes that I could take a look!

0 Kudos
Message 2 of 5
(3,304 Views)
Solution
Accepted by topic author LearningLabVIEW

It's not possible to remove a single element from a 2D array: you need to remove either an entire row (like in your case) or an entire column.

So, check if a row is completely blank: if so, remove it from the output. Hereafter an example. Right-click on the output tunnel to set is Conditional.

Remove rows.png

 

Edit: sorry! I re-saved the vi to LabVIEW 2017

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 3 of 5
(3,301 Views)

Thank you for this. I was trying to iterate through each individual one. This works perfectly. Did not even think to do it this way.

0 Kudos
Message 4 of 5
(3,286 Views)

Yes, you can only remove entire rows, of course.

 

Yes, there are many ways to do this. Here's my variation. 😄 Same difference!

 

altenbach_0-1673286673619.png

 

 

 

0 Kudos
Message 5 of 5
(3,241 Views)