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!