Finding min point of a second derivative function
조회 수: 5 (최근 30일)
이전 댓글 표시
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)
댓글 수: 0
답변 (1개)
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)')
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Linear Algebra에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!