05-17-2009 12:56 AM
Hello evryone!!
I have a huge 1D array and It has certain values which are like peaks when plotted. For example, the array may look like:
1 0.23 0.12 0.34 0.2 1.345 0.25 0.13 0.45 0.16 1.023 ---- As you can notice, the array has maximum values (magnitude close to 1) placed regularly. Now I need to find each of these maximum value and put them in an array. Currently I just start at iteration 0 of the array and use the array index function to get all of these peaks.
However,in this code, I assume that the first maximum peak occurs at element 0 (first iteration) of array. But this may not be the case and the array might look like:
0.23 0.12 1 0.24 0.34 0.15 0.19 1.023 0.45 0.51 0.21 0.3 1.345....etc. that is the first maximum value may not occur at the element 0 of the array. So the problem here is to find this first maximum peak and then as the others are placed at regular intervals, i can find them.
Could any one please suggest as to how i could change my code to find this first maximum/peak. thanks for the help:)
05-17-2009 01:22 AM
Have you tried the "peak detector" from the "signal processing..signal operation" palette?
If the peaks are truly equally spaced, you might even get the desired information from e.g. a fourier transform. The peak in the transform would give you the principal frequency and the phase of the peak would give you the shift.
Can you attach a VI containing some real data so we can play with it?
05-17-2009 01:45 AM
Hello again!!. I have attached my VI's.
Please note: The current issue is in the second for loop of the receiver.vi code. The peaks array output is the one which gives all the peaks found.
Thanks!!!
05-17-2009 02:47 AM
Well, the VI still has missing subVIs and I see no obvious resemblance to the peak finding problem. The second loop deals with a 2D array but earlier you were talking about a simple 1D array.
Why don't you do the following few steps
05-17-2009 04:09 AM
05-17-2009 05:08 AM
LSASS wrote:
You may not have observed their regular appearance becuse the peaks are seperated by 584 values which is huge.
I could not observe anything, because the original VI had no data at all and was not executable because of missing subVIs! 😉
Why don't you simply get the index of the first element that is above e.g. 0.5 as in the attached quick draft (LV 8.6)? Modify as needed.
(I also did some general cleanup, your code was way too complicated, e.g. way too many loops! ;))
05-18-2009 11:31 AM
Take a look at this example on the Dev Zone Community, it allows you to detect all the peaks in a data set above a given (setable) threshold.
05-19-2009 05:15 PM
Hi altenbach,
Thanks for the help. It works as I want it to. Also you removed may unnecessary for loops in my codde. This helped to reduce computation time....Thanks:)
05-20-2009 03:37 PM
Hi hunter,
The find a frequency peak with an adjustable peak threshold works only with inputs of signals. But my inputs are all arrays. so this will not work for me. thanks for the idea :).
05-21-2009 10:59 AM - edited 05-21-2009 10:59 AM
You can modify that example with this code