08-14-2012 12:25 PM
Hello,
How do I index an array at multiple locations?
I have searched this question and was not able to find the answer. I understand that it can be done with loops, but I do not know how.
I am using the peak detector vi for frequency domain data gathered (s2p file) from a VNA. The outputs contain an array of the amplitudes and an array of the locations. The problem is that the locations refer to the amplitude array index, which is not the same as the frequency. My idea is that I can use this output array of locations to index the frequency array at the detected peak frequencies, and then plot these, as well as doing some data analysis and manipulation on them. Currently, I can do this only by viewing the array on the front panel.
The input to the peak detector is currently a 1D array of the magnitude (is this the problem?).
I also looked at the Power & Frequency Estimate VI, but this VI seems to only output scalar data for the largest peak, not exactly what I am looking for.
Thanks for your help.
Solved! Go to Solution.
08-14-2012 12:34 PM - edited 08-14-2012 12:36 PM
Do you have a second array for the tested frequencies? If so, then you are correct that you just need to index that array with the indecies from the Peak Detector. Use a for loop. Autoindex on the indecies, use array index to get the frequency value, and autoindex out the frequencies.
08-14-2012 01:23 PM
If you have evenly spaced frequencies I would just do the math: freq[i] = f0 + df*Locations[i] (no loop required). If you have a frequency array I would use Interpolate 1D array instead of Index Array, or at the very least round the Locations to nearest before indexing the array.
08-14-2012 01:28 PM
Thanks crossrulz.
08-14-2012 01:32 PM
Darin,
Thanks for the input. Your solution seems that it would work as well in this case. I did round the location as well.