cancel
Showing results for
Did you mean:

## Re: Auto-indexing 2D Arrays

Active Participant

What is the value in Numeric Value Out following execution of the VI?

a) 13

b) 15

c) 30

d) 40

Member

Member

hi everyone...the answer is B. 2D becomes 1D and 1D becomes a scalar value.so only the elements 1,2,3,4,5 will be added with each other. please correct me if i'm wrong 🙂

regards
calvin
Member

am agree wid calvin, saki

Member

B is the good one ! But i disagree with your explanation calvin.

The first For loop selects the first line of the array :

The internal For loop iterates 5 time : 1+0 // 2+0 // 3+0 // 4+0 // 5+0 and return the final result 5+0=5 (because indexing mode is disable) to the shift register.

The first For loop selects the second line of the array :

The internal For loop iterates 5 time : 6+5 // 7+5 // 8+5 // 9+5 // 10+5 and return the final result 10+5=15 ! (because indexing mode is disable) to the shift register.

No more iteration for the first For loop so 15 is the Numeric value out !

NI Employee

I completely agree with BenoitP.

If the indexing mode had been enabled, the value would have been 115.

-Danny

Member

BenoitP....thanks for making it clear to me.could you expalin to me the working if Auto Indexing has been enabled?

regards
calvin
Member

Sure, i will try it.

When Auto Indexing mode is enable for an output : this output is an array

When Auto Indexing mode is disable for an output : this output is a scalar (specifically the last value of the array if auto indexing mode has been enabled).

So in this exemple,

If auto indexing mode has been enabled for the two output of Foor loop. The numeric value of the first For loop will be an Array 1D and not a Scalar and the output of the second one will be an Array 2D. This example will change completly !

If you want to well understand Indexing mode find others questions from SercoSteveB on this blog.

Active Participant

Yeah I agree with B, Benoit it`s great explanation... thanks buddy.

Member

Ans is B, this is because, we dont have a shift register for the inner for loop.

Member

thanks benoit...

regards
calvin
Active Participant

Answer: B.  Way too many correct answers to mention everybody by name (first time we have had so many).  Nice one.  A special shout out to BenoitP. for a couple of great explanantions.

Yep we need to know how the 2D array is auto indexed by the outer loop (does it index the rows or the columns of the 2D) and also we need to notice that the inner loop has standard tunnels and not a shift register, so all of the addition results, apart from the last one, are lost (overwritten).

Member

no clue at all

Knight of NI

The autoindexing will index off rows of arrays first.  So the array of the first iteration of the outside while loop is {1,2,3,4,5}.  The inner FOR loop will just iterate on this array.  But since we are not using a shift register (just a normal tunnel), only the last iteration matters.  So in the end, it is just 0+5=5.  Then the outer FOR loop uses the next row of the 2D array.  Since we are using shift registers, the 5 from the previous iteration is used in the addition.  This time we get 5+10=15.  So the answer is B.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines