LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I do second derivative for X and Y arrays

Dear friends,

How can I do the second derivative for X and Y arrays?
I have to find the maximum change in slope, but the problem is my dx(s) are not constant because they are the electrical signal measured.Any help is very appreciated.

Thank you so much,
0 Kudos
Message 1 of 21
(8,111 Views)
There are different techniques that can be used to compute your derivatives.

Before differentiating your signal, you may consider re-sampling it to a constant dx value. A smooth way to do that (up to second derivative) is to use the spline interpolation method. It is then easy to compute the derivatives.

I have modified your VI to show both your original data in an XY-plot and as a constant dt waveform after interpolation.
Message 2 of 21
(8,111 Views)
Thank you so much for your helpfulness. I'm so impressive for your modified vi. Do you have the vi that suggest me to use it to differentiate the new waveform 2 times?

Thank you again.
0 Kudos
Message 3 of 21
(8,111 Views)
Use for example the VI "Derivative x(t).vi" located in the Analyze>>Signal Processing>>Time Domain palette. The VI processes your Y(t) array. Remember to enter the dt value (the one you specified for the Spline interpolation). You can also enter an appropriate initial value condition to the VI to avoid mis-leading result values at the beginning, or you can choose to ignore the first few points of your differentiated result. (same considerations with final conditions and/or ignoring the last few points)
0 Kudos
Message 4 of 21
(8,111 Views)

What happens when you use Derivative x(t) in series to calculate second derivative.

 

I am getting strange answers.  How to initialise in this instance?  Is there a better way of performing second derivative?

 

I have used "nth Derivative of Polynomial.VI".  It has no inital condition inputs.

 

What is the correct way?

0 Kudos
Message 5 of 21
(7,638 Views)

Did you realize that this thread is 5 years old? 😮

 

Taking the second derivative can be very noisy, so you would also need some filtering. How does the data look like?

 

If you can fit it well with a polynomial, you could use "nth Derivative of Polynomial.VI" on the resulting coefficients to generate the coefficients for the nth derivative polynomial. Apply your x-values and the new coefficients to "polynomial evaluation" to generate the curve for the second derivative (You don't even need equal spacing in x).

 

Can you show us some example data?

0 Kudos
Message 6 of 21
(7,634 Views)

Yep I knew it was an old thread.

 

An example of actual measured data is:

 

a =          pa =

2.5          320

5             245

7.5          182

10           162

12.5        168

15           152

 

Typically though there will be around twice the number of datapoints.

 

It appears that the Savitzky-Golay 2nd derivative operation is discontinuous at the start and end points.

 

How do you get around this?

0 Kudos
Message 7 of 21
(7,609 Views)

Was a technique found for this? I am having the same problem. The first derviative looks good and even better when I filter, but when I take the second derivative the plot looks horrible and not as expected. I have basically a Gaussian peak that I need to take the 2nd derivative of. The polynomial solution doesn't fit well.

Doug Ferguson

www.southerndaqsolutions.com
0 Kudos
Message 8 of 21
(6,100 Views)
Hi Doug, you read this thread?
You might want to supply a VI with sample data...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 21
(6,094 Views)

GerdW,

 

I did indeed read the thread. Its kind of insulting to assume I did not.

 

The suggestions made in this thread were pretty basic and obvious. I already have evenly spaced data so no need to fit using the spline interpolation method. Secondly, I have a Gaussian peak, so taking the derivative using the nth Derivative of Polynomial.VI doesn't yield the results I expect based on publications for peak identiciation in high pressure liquid chromatography. Lastly, I don't feel it necessary to attach a VI of an evenly spaced array being fed into the Derivative x(t) VI  with and without various filter VIs attached. The real crux of the issue is that several of us have had issue with LabVIEW's Derivative x(t) VI giving unexpected results when used to find the 2nd derivative. Has anyone found a better solution?

Doug Ferguson

www.southerndaqsolutions.com
0 Kudos
Message 10 of 21
(6,070 Views)