LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in Build Array Function - Inserted to row 1 instead of row 0

Solved!
Go to solution

Using the build array block;

Step 1: Concatenate a 2D empty array with a 1D empty array = empty 2D array, 

Step 2: Concatenate a 1D array of data with an empty 1D array = 1D array

Step 3: Concatenate the 1D into the 2D and you get the 1D at row 1 instead of row 0

 

This can be fixed by transposing the empty 2D array created in step 1 before concatenating in step 3.

I'm a bit perplexed by this.Why would transposing an "empty" 2D array fix anything

0 Kudos
Message 1 of 7
(3,008 Views)

Hi Hefminster,

 

it's because your "Empty 2D array" contains a row:

check.png

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 7
(2,996 Views)

Why does the Empty 2D array contain a row? Nothing + nothing = nothing?

0 Kudos
Message 3 of 7
(2,985 Views)
Solution
Accepted by topic author Hefmister

@Hefmister wrote:

Why does the Empty 2D array contain a row? Nothing + nothing = nothing?


Not entirely correct.  When adding a 1D array to a 2D array, the 1D array goes in the N index (where N is the number of rows) and then N is incremented.  So the empty 1D array goes into row 0 and the length is incremented to be 1 (number of rows is 1, number of columns is still 0).  So when a real array gets added to the resulting 2D array, it goes into row 1 and the length incremented to 2.

 

There are plenty of debates floating around on similar issues with empty arrays and them having length.  This one actually seems like a bug to me.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 7
(2,962 Views)

Hi crossrulz, thanks for the explanation. I don't think this can be "solved" in its raw form without a change in behaviour from Labview. I'll mark it as solved as we have some idea of what's going on.

 

0 Kudos
Message 5 of 7
(2,952 Views)

Why are you building an empty array onto an empty array?

 

What do you expect the result to be?  I know you are going to say and empty array.  Which is what you did get because there are no elements existing in that array.  But the rules how the dimensions of the array are handled need to be followed consistently whether the arrays are empty or have data.

 

If you have a 4 row by 3 column array and add a row, you expect to finish with a 5 row by 3 column array.

If you have a 0 row by 0 column array and add a row, then using the same array manipulation rules, you'll have a 1 row by 0 column array.

0 Kudos
Message 6 of 7
(2,946 Views)

I see your logic.

To answer your question as to why I'm building an empty array onto an empty array...I can't show the actual code I'm debugging, instead I've stripped out the non essential components and attached it. This code is used in a chain where data is received and turn it into bitmaps.

 

Unexpected Row of Zeros Bug V2.png

 

0 Kudos
Message 7 of 7
(2,934 Views)