The graph doesn't disply
2 次查看(过去 30 天)
显示 更早的评论
Sorry for repeating the question so many times. I try to display the graph, but the marked part does not appear. Can you help me?
clc; clear all; close all;
fun =@(t) (1/200).*t.^2+(1/500).*exp(-0.2.*t)+5;
dgraph = @(point, dfda, t) dfda*t + (fun(point)-dfda*point);
est_point=150;
da=2;
dfda_true=(1/100).*(150)+(-0.2./500).*exp(-0.2.*(150));
dfda_forward = (fun(est_point+da)-fun(est_point))./da;
dfda_backforward=(fun(est_point)-fun(est_point-da))./da;
dfda_center=(fun(est_point+da)-fun(est_point-da))./(2.*da)
a=-50:0.01:150;
figure(1)
plot(a,fun(a),'k'); hold on;
plot(a, dgraph(est_point,dfda_true,a),'b'); hold on; %dosen't work
plot(a, dgraph(est_point,dfda_center,a),'r'); hold on;
0 个评论
采纳的回答
Star Strider
2024-5-22
It actually does work. The problem is that the red line overplots it since it is plotted later, and hides the blue line. If you make the blue line wider (I set 'LineWidth',3 here) the blue line shows up.
Try this —
% clc; clear all; close all;
fun =@(t) (1/200).*t.^2+(1/500).*exp(-0.2.*t)+5;
dgraph = @(point, dfda, t) dfda*t + (fun(point)-dfda*point);
est_point=150;
da=2;
dfda_true=(1/100).*(150)+(-0.2./500).*exp(-0.2.*(150));
dfda_forward = (fun(est_point+da)-fun(est_point))./da;
dfda_backforward=(fun(est_point)-fun(est_point-da))./da;
dfda_center=(fun(est_point+da)-fun(est_point-da))./(2.*da);
a=-50:0.01:150;
figure(1)
plot(a,fun(a),'k'); hold on;
plot(a, dgraph(est_point,dfda_true,a),'b', 'LineWidth',3); hold on; %dosen't work
plot(a, dgraph(est_point,dfda_center,a),'r'); hold on;
.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!