The graph doesn't disply

1 次查看(过去 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;

采纳的回答

Star Strider
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;
.
  2 个评论
재훈
재훈 2024-5-22
Thank you so much for your help. have a good day! cheers:)
Star Strider
Star Strider 2024-5-22
As always, my pleasure!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Directed Graphs 的更多信息

产品


版本

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by