LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

derivative of unequally sampled data

Hi there,

 

I need 1st & 2nd derivative of attached sampled data.

As you can see the time between two consecutive samples is not equal. 

What should I wire to the dt input of the Derivative x(t).vi? 

 

Thanks for any comment!

0 Kudos
Message 1 of 10
(3,680 Views)

hi

if the variation is known, I would interpolate these to the function then take the analytical derivativ..

otherwise you have to stick to numeric ones, it can be messy for the second derivative.. 

N

0 Kudos
Message 2 of 10
(3,643 Views)

Hello,

 

Is there a specific reason why the data is not sampled at a constant rate?

Is there a mathematical link between the succeeding sample times?

 

Message Edited by ThiCop on 03-22-2010 03:27 AM
Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
0 Kudos
Message 3 of 10
(3,622 Views)

ThiCop wrote:

Hello,

 

Is there a specific reason why the data is not sampled at a constant rate?

Data comes from a testing machine and I can't get an equal sample rate out of it 😞

 

 

Is there a mathematical link between the succeeding sample times?

I think there's always a mathematical link between data points, question is "Do you need a 3th or 20th order polynomial to fit both?"

Message Edited by ThiCop on 03-22-2010 03:27 AM

I tried to fit a polynomial through the data and then resample the data with a constant dx, but depending of the order of the polynomial used I get different 1st and 2nd deriative results.

That's why I asked for another more robust calculation method.

0 Kudos
Message 4 of 10
(3,613 Views)

I meant: Is there a mathematical link between the timestamps. Because then you could use something similar to a greatest common divisor to interpolate to the time points in between.

 

Do you have any prior knowledge over how your system should react?

 

Fitting the whole set of sample points (which I assume you've done) to a model is never a robust technique. Using a higher order polynomial will then always make your fitting (seem) better. 

But you can make the fitting approach a bit more robust by creating two sets of data.

 

If you split your original set of sample points up into a "fitting" set and a validation set, then you can create your xth order polynomial based on the "fitting" set. 

 

When your polynomial is known, then you can test your "fit" with the validation set. By comparing the sum of the absolute differences between the expected answer (by the fit) and your values in the validation set you get an idea of the error made by the xth order fit.

 

You can repeat this then for every order x (of the polynomial) that you want to check. 

While you're gradually increasing the order x you'll see that at first the error will decrease, but at some point it will start to rise. This way you can determine a sufficient order (the ones with the smallest errors) to use.

 

The weak points in this method are the choice of the size of the set ("fitting" & validation), the range of orders you check and which points you choose for each set (never chose the first or the last point for your validation set, because most fitting/modelling techniques cant guarantee anything outside the fitting range).

 

PS: Personally I prefer using modelling techniques over fitting techniques because in the latter the presence of noise in the measurements is ignored and not modelled.But for some cases fitting techniques can be adequate.

 

 

 

 

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
0 Kudos
Message 5 of 10
(3,602 Views)

Hi,

 

Here is my attempt to do what I think you want. Its in LV2009.

 

cheers

 

David

0 Kudos
Message 6 of 10
(3,587 Views)

Thanks for your efforts David but I'm still with LV8.5 so............ you know 🙂

Thanks a lot

Alain

0 Kudos
Message 7 of 10
(3,564 Views)

Saved in 8.5.

 

cheers

 

David

0 Kudos
Message 8 of 10
(3,539 Views)

Thanks for the efforts David!

Basically you get the same shape as with the polynomial fit but you have some noise on the first derivative Smiley Surprised

That noise makes it impossible to get a valuable 2nd derivative 😞

0 Kudos
Message 9 of 10
(3,499 Views)

Alain,

 

Can you use a median filter to "clean up" your first derivative before taking a second?

 

David

0 Kudos
Message 10 of 10
(3,494 Views)