2nd 3rd derivatives
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Muhammad Rohaan
am 1 Okt. 2022
Bearbeitet: Torsten
am 2 Okt. 2022
trying to plot first 3 derrivatives for the following function: y = exp(-3.*x)
x = [-2:0.01:1];
y = exp(-3.*x);
dy=diff(y)./diff(x);
d2ydx2=diff(y,2)./diff(x,2);
plot (x(3:end),d2ydx2)
it plots the original function and first derrivative but gives a weird graph for 2nd derrivative
any help would be appriciated
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Torsten
am 1 Okt. 2022
Bearbeitet: Torsten
am 2 Okt. 2022
x = [-2:0.01:1];
y = exp(-3.*x);
dydx = diff(y)./diff(x);
d2ydx2 = diff(dydx)./diff((x(1:end-1)+x(2:end))/2);
d3ydx3 = diff(d2ydx2)./diff(x(2:end-1));
figure(1)
hold on
plot((x(1:end-1)+x(2:end))/2,dydx)
plot((x(1:end-1)+x(2:end))/2,-3*exp(-3*(x(1:end-1)+x(2:end))/2))
hold off
figure(2)
hold on
plot(x(2:end-1),d2ydx2)
plot(x(2:end-1),9*exp(-3*x(2:end-1)))
hold off
figure(3)
hold on
plot((x(2:end-2)+x(3:end-1))/2,d3ydx3)
plot((x(2:end-2)+x(3:end-1))/2,-27*exp(-3*(x(2:end-2)+x(3:end-1))/2))
hold off
0 Kommentare
Siehe auch
Kategorien
Mehr zu Line Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!