![234.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/249146/234.png)
Calculate derivative using central differencing
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Kyle Lazaroff
le 20 Nov 2019
Commenté : Kyle Lazaroff
le 20 Nov 2019
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 commentaires
Réponse acceptée
KALYAN ACHARJYA
le 20 Nov 2019
Modifié(e) : KALYAN ACHARJYA
le 20 Nov 2019
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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!