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.
07-06-2015 02:06 AM - edited 07-06-2015 02:07 AM
Hi guys,
In this VI, I meant to remove empty elements in array. It worked for 1D array but as soon as I gave it 2D array, for some reason I was unable to remove empty elements:
Solved! Go to Solution.
07-06-2015 02:17 AM
Try transposing the array before and after the for loop. Looks to me like it is indexing the other way round from what you expected...
07-06-2015 03:08 AM
Hi cryptic username,
in an 2D array ALL rows need to have the same number of columns!
So even when you delete elements from row 2 it will still have two (empty) elements when row 1 has two ("non-empty") elements!
When you want to remove rows as well you need the same conditional output tunnel as you already use for the columns in the inner loop…
07-06-2015 03:39 AM
Hi GerdW,
So when I was debugging, I saw at the 3rd row and 4th row iteration, the output from inner FOR loop to index terminal of outter FOR loop is [].
Shouldn't the index terminal of outer loop treat [] as "skip this" ?
I mean what you described definitely applies if [ ] has some element but in this case it has none. To prove the point, try something like this:
07-06-2015 03:59 AM - edited 07-06-2015 03:59 AM
Hi funny username,
Shouldn't the index terminal of outer loop treat [] as "skip this" ?
Why should it?
All it has to follow is DATAFLOW!
I mean what you described definitely applies if [ ] has some element but in this case it has none.
It always behaves the same way. And it follows DATAFLOW!
To prove the point, try something like this:
Your example is WRONG as you compare apples with oranges!
In your first post you had non-empty 1D arrays and in your last post you have always empty arrays…
07-06-2015 05:28 AM
@sdfsdfsdfadgadf wrote:
So when I was debugging, I saw at the 3rd row and 4th row iteration, the output from inner FOR loop to index terminal of outter FOR loop is [].
Shouldn't the index terminal of outer loop treat [] as "skip this" ?
In that case, the indexing tunnel in the outer loop takes an empty 1D array and appends it as a row to the 2D array. Because 2D arrays can't be jagged, it fills the remaining elements of the row (all of them) with the default value. You could possibly argue that an empty array should mean "don't append at all", but this behavior goes back a long way and I'm not sure what kind of effect this would have. As mentioned, it's easy enough to do what you want with a conditional append in the outer loop.
@sdfsdfsdfadgadf wrote:
I mean what you described definitely applies if [ ] has some element but in this case it has none. To prove the point, try something like this:
Check the array size. You will find it is 3,0,0. That is, you have 3 pages, each with an empty 2D array, which is exactly what your code builds.
I try to avoid dealing with >2D arrays and dealing with cases where they can be empty, so I don't remember the details of why this happens, but IIRC, it does follow from the rules of the system.
07-07-2015 12:21 AM
Thanks tst for pointing out the array size is 3 empty array. That explained a lot !