LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Extracting Points Where Slope is Zero from Plot

Solved!
Go to solution

Hello,

I have been going a this for awhile and haven't been able to figure it out so any help would be appreciated.

 

I'm trying to extract the values corresponding to the bottom of a valley (slope = 0) for an arbitrary data set of XY values.

I've attached a pick of a sample set of data; probably helps clear up what I'm trying to do.

As shown in the pic, I'd like to extract the valley value pairs (e.g. 21.1925, 0.420687 & 24.4725, 0.420651)

 

I've tried taking the derivative but it only yields one of the values....always have at least two solutions.

tried working with a polynomial interpolation adn that went south quickly...no idea what happened there.

 

Anyway if you have a suggestion I'd appreciate it

best

SS

0 Kudos
Message 1 of 9
(3,344 Views)
You could try this function Derivative x(t) VI, owning Palette: Integ & Diff VIs. This function is not included in LV base. It is quite hard to get a signal 100% flat. So I recommend that you use some sort of "in range" search


Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
Message 2 of 9
(3,336 Views)

If you take the gradient of your data, as suggested by Coq rouge, then you want to be looking for regions where the polarity of the gradient switches from positive to negative (for local maxima) or negative to positive (for local minima). This would be better than looking the values themselves, because, as Coq rouge identified, you are very unlikely to get gradients of 'zero', and if you were to include a range (say -0.01 to 0.01) then you won't find the true minima/maxima.

 

So, take your gradient (derivative) and pass it through a greater-than-zero comparator, resulting in an array of booleans. At each index where the booleans switch from false to true you have found a local minimum, and where they switch from true to false you have found a local maximum.

 

This is my theory anyway - I'm sure there's probably a better way if anyone has any more ideas? Smiley Very Happy

Thoric (CLA, CLED, CTD and LabVIEW Champion)


Message 3 of 9
(3,325 Views)
Sorry I did not read all your text as thorough as I should have. Labview do have a peak/valley detector. It is called Peak Detector VI. Owning Palette: Signal Operation VIs. It is not always 100% accurate so you may do some fine tuning on the results. But with fine tuning it works OK. At least for me. A more simple peak/valley detector can be made by at your current sample index comparing the values at previous and next index. If both are lager you have a local minima value. Combine with a threshold value


Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
Message 4 of 9
(3,318 Views)
How much noise do you expect in the data? Can you attach a typical datafile? A piecewise polynomial fit might work just fine, you can get the right points by compariing the first and second derivatives, easily calculated from the polynomial coefficients.
Message 5 of 9
(3,298 Views)
You can get polynomial fit derivatives relatively easily using the Savitzky-Golay VIs in newer versions of LabVIEW.  Your problem is then finding the zeroes of the function, which is also easy in LabVIEW.  Look at the root finding VIs.  Do not use the derivative VI, since it is a simple linear calculation, so is very noise sensitive.
Message Edited by DFGray on 04-27-2009 08:43 AM
Message 6 of 9
(3,240 Views)

thanks for all the suggestions. I've tried implementing them but think that what I've arrived at isn't all that clean...think it could be simpler.

I've attached the VI (in Labview 8.0) so if you have any ideas I'd appreciate it the help.

 

best

SS

0 Kudos
Message 7 of 9
(3,212 Views)
Solution
Accepted by topic author SurfaceSurfer

I hope I do not end up in a Janet Jackson Super Bowl situation for showing thisSmiley Very Happy. But all kidding aside I why are you not trying the tip I gave you in my message dated 04-24-2009 01:01 PM. As I said with some tuning you should get the desired result. I tested it and it works fine see picture.

 

Message Edited by Coq rouge on 04-28-2009 11:45 AM


Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
Message 8 of 9
(3,194 Views)

Better watch out foir the case where the "Valley" is not a valley but can still be considered a "point of inflexion".  This arises when the gradient goes from positive -> approches zero -> goes positive again (Or -ve, -->0, -ve).  Thus the differential AND the sign change before and after the point of inflection is needed

 

Craigc

LabVIEW 2012
0 Kudos
Message 9 of 9
(3,183 Views)