The code doesn't work....
Afficher commentaires plus anciens
hello everyone
I am practicing numerical differentiation. However, the numerical analysis values and actual values do not appear on the graph at the same time and seem to conflict. Where did we go wrong? Thank you for reading this long sentence. have a good day:)
here is my code :
clc; clear all; close all;
fun = @(t) -0.01953125.*t.^2 + 18.75.*t
est_point = 100;
da = 1;
dfda_central = (fun(est_point + da) - fun(est_point - da))./2*da
x = 0:0.01:960;
fx = fun(x);
dfda_true = -0.0390625.*est_point + 18.75
dgraph = @(point, dfda, t) dfda*t + (fun(point) - dfda*point);
figure(1)
plot(x,fx,'black','linewidth',2); hold on;
plot(x, dgraph(est_point, dfda_central, x),'red'); hold on;
plot(x, dfda_true,'blue'); hold on;
grid on;
rel_error=norm(dfda_true-dfda_central)/norm(dfda_true);
disp(rel_error);
disp(dfda_true);
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
