How to take first and second order derivative of discrete data?
Ältere Kommentare anzeigen
Hi, I have two discrete signals with constant time intervel dt=0.01, one is y(t) (displacement), one is Cl(t) (force). Each signal is a vector with 200000 elements, and I don't know the function expression of them, so I use numerical difference technique in matlab to take first and second derivatives. I use the second-order accuracy central difference method, i.e. gradient() function in matlab.
The code is:
load t.mat y.mat Cl.mat
% take 1st and 2nd derivative of y(t)
dy = gradient(y)./gradient(t);
ddy = gradient(dy)./gradient(t);
% take 1st and 2nd derivative of Cl(t)
dCl = gradient(Cl)./gradient(t);
ddCl = gradient(dCl)./gradient(t);
% plot y, y', y''
subplot(3,2,1)
plot(t,y,'k-'); ylabel('y');
subplot(3,2,3)
plot(t,dy,'r-'); ylabel('y\prime');
subplot(3,2,5)
plot(t,ddy,'r-'); ylabel('y\prime\prime');
% plot Cl, Cl', Cl''
subplot(3,2,2)
plot(t,Cl,'k-'); ylabel('Cl');
subplot(3,2,4)
plot(t,dCl,'r-'); ylabel('Cl\prime'); xlim([200 2000])
subplot(3,2,6)
plot(t,ddCl,'r-'); ylabel('Cl\prime\prime'); xlim([200 2000])
The results is shown below.

The direct numerical difference of signal 1 (y) seems to obtain good results, while the second derivative of signal 2 shows weired shapes, it is not like noise but with some repeated pattern.
How can I filter or smooth the second signal to obtain correct derivatives? Ang suggestion is welcome! Thanks!!!
1 Kommentar
Ying Wu
am 16 Dez. 2022
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu State Estimation finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
