07-11-2012 06:56 AM
Hi!
I have a signal that i take in from a PXI 5600 and store it in an array. What i want to do is to find the peak of the signal (this i have done succesfully) and then calculate the bandwidth.
What i do now is to take the peak value and calculate 20dB, then i use the "1 D Array search" but i get the index -1. My guess is that this is happening because of that the array doesnät contain EXACTLY the calculated value.
Can i somehow search the array for the values around the calculated one? For example; if i calculated the value 10.08 i want to search for everything between 9.9 - 10.1.
then i wonder how i can plot these points whith a line between them in my already power spectrum
Solved! Go to Solution.
07-11-2012 07:08 AM - edited 07-11-2012 07:09 AM
07-11-2012 07:14 AM
Use Threshold 1D Array rather than Search. You are correct that Search looks for exact values and that you will almost never find then with floating point data. The Threshold function returns a fractional index that represents the interpolation of the data bewteen indexes when the data is not an exact match.
The detailed help explains the -1 index value returned. If you are not in the habit of keeping context help on while porgramming and looking at details when you do not understand how something works, try it. The detailed help for the Search function includes a link to the Threshold function and a brief explanation of when it might be the better choice.
Lynn
07-11-2012 07:19 AM
07-11-2012 07:54 AM - edited 07-11-2012 07:58 AM
Make a subVI that contains a for loop. Have the loop exit when the value is within your range.
07-11-2012 07:54 AM
GerdW,
Right.
If the signal is very clean so that noise is not an issue, extracting array subsets before and after the peak and then reversing and possibly inverting the arrays could make the Threshold function work.
Regardless, some programming will need to be done to find the specified points.
Lynn
07-12-2012 02:36 AM
I like this way a bit better than GerdW just because of the indexing part, i need it to calculate the frequency. But i'm having 2 problems:
1 - The loop condition will not connect as you did. It says : "Connecting two terminals of different types .
The type of the source is 1-D array of
boolean (TRUE or FALSE).
The type of the sink is boolean (TRUE or FALSE).
2 - I will get the first value this way. But how can I search the other value (value after the peak). Do i have to create a new array that starts from the index where the peak is?
07-12-2012 02:42 AM
Hi Firas,
to search errors it is always helpful to attach the VI or at least a snippet/picture of the BD!
Then you should also make clear which example you used...
Then:
- When the comparison results in an array you can change the comparison mode, index the arrays before the comparison or after. It depends on what you have programmed - and you didn't show that...
- When you do it my way you get a boolean array. You can search that array for your interesting points using "Search 1D Array"...
07-12-2012 03:11 AM - edited 07-12-2012 03:15 AM
Sorry, thought i quoted the solution i used.
I think i get your solution now and i've attached a print of what im doing. As i said before i have a peakvalue and want to calculate the bandwith, that means one point at -20dB to the left of the peak and one point to the right.
Im still getting -1 from the array searchs. I dont get whats wrong:S
Link to the pic: http://img221.imageshack.us/img221/5857/95828741.jpg
07-12-2012 03:14 AM - edited 07-12-2012 03:17 AM
Hi Firas,
always upload picture here in this forum! Your imageshack-file is resized - and it's link is malformed...
So you got that on your own... No, you don't got that...
- You don't need a sequence structure for that calculation...
- Attach a VI with some example data: make an indicator showing your waveform. Create a constant from that indicator and save the vI. Attach it...