03-05-2020 01:25 PM
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?
Solved! Go to Solution.
03-05-2020 01:48 PM
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?
03-05-2020 02:04 PM
I can show you my app in parts. In here first loop is starting. I got 13 files.
In here second loop's index is defined.
On the next screen you can see part I showed befor.
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.
03-05-2020 02:07 PM
I wrote everything to file and it looks like this...
03-05-2020 02:25 PM
@Kamila_Jankowska wrote:
In here second loop's index is defined.
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.
03-05-2020 03:16 PM
Thank you very much, you really helped me. It was a stupid mistake. I thought it works in diffrent way...
03-05-2020 03:20 PM
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.