![234.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/249146/234.png)
Calculate derivative using central differencing
1 回表示 (過去 30 日間)
古いコメントを表示
dx = 0.01;
x = 0:dx:2*pi;
signal = sin(x).*cos(10*x);
dsignaldx_true = cos(x).*cos(10*x) - 10*sin(x).*sin(10*x);
dsignaldx_forward = ForwardO1(signal, x);
dsignaldx_central =
for i =
end
error_forward_max = max(abs(dsignaldx_forward(2:end-1) - dsignaldx_true(2:end-1)));
fprintf('The maximum relative error encountered when using forward differencing with O(dx) error is %f\n', error_forward_max)
error_central_max =
fprintf('The maximum error encountered when using central differencing with O(dx^2) error is %f\n', error_central_max)
error_forward_average = mean(abs(dsignaldx_forward(2:end-1) - dsignaldx_true(2:end-1)));
fprintf('The average error encountered when using forward differencing with O(dx) error is %f\n', error_forward_average)
error_central_average =
fprintf('The average error encountered when using central differencing with O(dx^2) error is %f\n', error_central_average)
0 件のコメント
採用された回答
KALYAN ACHARJYA
2019 年 11 月 20 日
編集済み: KALYAN ACHARJYA
2019 年 11 月 20 日
Is this?
![234.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/249146/234.png)
dx=0.01;
x=0:dx:2*pi;
signal=sin(x).*cos(10*x);
diff_cen=(sin(x+dx).*cos(10*(x+dx))-sin(x).*cos(10*x))/(2*dx);
diff_cen
# I hope, rest you will do
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!