The code doesn't work....
显示 更早的评论
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);
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
