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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Spectral measurments array indexing in loop

Solved!
Go to solution

Hi,

I am using Spectral measurments block in two nested loops. I want to add all values to array with indexing tunnel mode, but everything is raplaced by the last value. Size of array is correct. Could anyone  give an explanation?

Kamila_Jankowska_0-1583436172684.png

 

0 Kudos
Message 1 of 7
(2,234 Views)

Unfortunately you don't show us much in that tiny piece of screenshot.  I couldn't even tell at first there were two loops. That inner loop is squashed pretty type to the sequence frame.  I recommend running block diagram cleanup to allow it to space things out and straighten up wires.

 

How do you know it is only giving you the last value?  We don't see your input data or output data on that picture.

 

It is possible that one of the loop is only running 1 time?

 

 

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

I can show you my app in parts. In here first loop is starting. I got 13 files. 

Kamila_Jankowska_1-1583438212189.png

In here second loop's index is defined.

Kamila_Jankowska_2-1583438306463.png

On the next screen you can see part I showed befor.

Kamila_Jankowska_3-1583438385055.png

I know that last value i replacing everything because I tried changed max index of second loop and I received diffrent values. I know that is hard to find something in expanded application like this but I was thinking that it is something about spectral measurment block.

Finally I need values from every loop in last array in here.

Kamila_Jankowska_4-1583438688175.png

 

 

 

 

0 Kudos
Message 3 of 7
(2,201 Views)

I wrote everything to file and it looks like this...

Kamila_Jankowska_0-1583438865832.png

 

0 Kudos
Message 4 of 7
(2,198 Views)
Solution
Accepted by topic author Kamila_Jankowska

@Kamila_Jankowska wrote:

 

 

In here second loop's index is defined.

Kamila_Jankowska_2-1583438306463.png

 


This looks strange to me.  You create an array of 3 waveforms.  Feed that into a For Loop hard wired to run 3 times.  Then inside you index out a waveform based on N (which equals 3) minus 1.  So you'll have 3 iterations of index 2 which is always the 3rd waveform in that array.

 

Is that what is happening?

 

You should get rid of the 3 constant and the index array, and the subtraction and the 3 constant.  (Note there is a decrement (-1) function in the numeric palette wich is easier than subracting a 1.)  Then just turn on the tunnel to be auto-indexing.  Then you'll get index 0, 1, and 2 in order.

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

Thank you very much, you really helped me. It was a stupid mistake. I thought it works in diffrent way...

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

Glad I could find it and help.

 

If you had wired from the i terminal instead of N -1 to the Index Array function, you'd be okay.

But that is completely unnecessary when auto-indexing tunnels give you what is essentially a "For Each" loop where the For Loop acts on each element of the array and stops when the array is done. 

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