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!
