The graph doesn't disply
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Star Strider
le 22 Mai 2024
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 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!