LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I index an array at multiple locations?

Solved!
Go to solution

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.

 

 

0 Kudos
Message 1 of 5
(2,517 Views)
Solution
Accepted by topic author KevinK1

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.


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 2 of 5
(2,512 Views)

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.

Message 3 of 5
(2,496 Views)

Thanks crossrulz.

0 Kudos
Message 4 of 5
(2,491 Views)

Darin,

 

Thanks for the input. Your solution seems that it would work as well in this case. I did round the location as well.

0 Kudos
Message 5 of 5
(2,489 Views)