How to properly take derivative of discrete data ?

56 ビュー (過去 30 日間)
Ole
Ole 2015 年 12 月 30 日
編集済み: Rohit Garud 2020 年 8 月 16 日
Taking derivative of discrete data requires some fitting and then using the b-form of the polynomial.
How to make a 'good' fit and properly take derivative? I am confused what is the right behavior of the derivative. Things change quite rapidly with small adjustments of the fitting scaps coefficient 0.09 in the example below.
The test.txt data is attached.
T = load('test.txt'); x = T(:,1); y=T(:,2)
pp22 = csaps(x,y,0.09);%some fit b-form
pp22val = ppval(pp22,x);
figure(1012)
plot(x,pp22val,x,y) %quality of fit
p_der202 = fnder(pp22,2);
y_prime22 = ppval(p_der202,x); % values
figure(101)
plot(x,y_prime22)

回答 (1 件)

Rohit Garud
Rohit Garud 2020 年 8 月 16 日
編集済み: Rohit Garud 2020 年 8 月 16 日
You can use the gradient() function in newer versions of matlab
dy_by_dx = gradient(y(:)) ./ gradient(x(:))

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by