Finding min point of a second derivative function

조회 수: 1 (최근 30일)
Harel Harel Shattenstein
Harel Harel Shattenstein 2018년 7월 8일
답변: Eduard Reitmann 2018년 8월 3일
What I have done is:
f=@(x)2./sqrt(pi).*integral(@(t)exp(-t.^2),0,x);
fplot(f,[-5,5])
DELTA=0.01;
X=-5:DELTA:5;
Y=f(X);
DY_DX=diff(Y)./DETLA;
But it does not work, is there an easier way to the first/second derivative? (not symbolic)

답변 (1개)

Eduard Reitmann
Eduard Reitmann 2018년 8월 3일
You were almost there. Hope this helps. The zero in the differential is a bit crude (just to keep the vectors the same length), but a small enough step size should give you are very accurate answer.
f = @(x) (2./sqrt(pi)).*integral(@(t) exp(-t.^2),0,x);
dx = 0.01;
x = (-5:dx:5)';
y = arrayfun(f,x);
dydx = [0;diff(y)./dx];
d2ydx2 = [0;diff(dydx)./dx];
[dy2d2x_min,minpos] = min(d2ydx2);
x_min = x(minpos)
figure;
plot(x,[y dydx d2ydx2],x_min,dy2d2x_min,'*')
legend('erf(x)','erf''(x)','erf''''(x)')

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by