LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Having issues in find the exact location of the peaks.

Solved!
Go to solution

Hi All, 

 

I am a new Labview user and having issues in finding the exact location of the peaks. I tried modifying the example of peak detection vi as per my requirement but couldn't figure out two issues,

1) the x-axis of the plot should be 900 to 1300 but showing 0 to 400. 

2) Giving the wrong peak locations.

 

Your help will be greatly appreciated. 

Download All
0 Kudos
Message 1 of 11
(2,389 Views)

Hi Hassan,

 

1) the x-axis of the plot should be 900 to 1300 but showing 0 to 400.

You are creating a new x axis, starting from zero: so why do you wonder about this behaviour?

 

2) Giving the wrong peak locations.

It is giving the correct peak locations as described in the LabVIEW help: as sample index in the sample array!

You need to convert those indices back to your x locations using the x axis from your CSV file!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 11
(2,373 Views)

Hi, 

 

1) I got your point. The for loop shouldn't be there. 

2) What is the formula to convert sample indices back to x location. 

 

Thank you. 

0 Kudos
Message 3 of 11
(2,349 Views)

Hi Hassan,

 

2) What is the formula to convert sample indices back to x location.

You can use options:

  • Use IndexArray with peak location as index into your X values array.
  • Use Interpolate1DArray with peak location as index into your X values array…
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 11
(2,346 Views)

maybe similar problem solved here

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 5 of 11
(2,323 Views)

Hi GerdW, 

 

I am still struggling to get the right peak locations. I understand what you meant but unfortunately couldn't do it in Labview. Can you please add these bits "

  • Use IndexArray with peak location as index into your X values array.
  • Use Interpolate1DArray with peak location as index into your X values array"

 to get the desired peak locations? 

 

Regards

Hassan 

Download All
0 Kudos
Message 6 of 11
(2,292 Views)
Solution
Accepted by topic author HassanIqbal

Hi Hassan,

 

I understand what you meant but unfortunately couldn't do it in Labview.

Did you even try to use one of those options? Why don't you show what you have tried?

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 11
(2,287 Views)

You have the "Locations" values as an array of DBLs.

Copying from the already mentioned help:

Locations contains the index locations of all peaks or valleys detected in the current block of data. Because the peak detection algorithm uses a quadratic fit to find the peaks, it actually interpolates between the data points. Therefore, the indexes are not integers. In other words, the peaks found are not necessarily actual points in the input data but may be at fractions of an index and at amplitudes not found in the input array.

 

If you want to get the value of the X array given an X index, you can either

  1. Use Index Array. This requires an integer value - you could consider using Round to Nearest (or Round towards -Inf, if you're concerned about an out-of-bounds access)
  2. Use Interpolate 1D Array - the help file can provide more details, but given you have an array of X values and an X index, it should be simple enough to work out how to wire this function to provide an interpolated X value.

Note that for both of these solutions, you'll probably need to provide a For loop to go through your list of locations. Take care not to allow indexing of the X array at the input tunnel.


GCentral
Message 8 of 11
(2,284 Views)

Hi GerdW.

 

Thank you so much for doing it.

 

I wasn't disabling the index of the For loop. 

Regards

Hassan 

0 Kudos
Message 9 of 11
(2,276 Views)

Hi, 

 

I was making the mistake you mentioned at the very end of your comment. Thank you very much for your detailed help. 

Regards

Hassan 

0 Kudos
Message 10 of 11
(2,273 Views)