MATLAB: Curvature of a discrete function

curvature

Hello,
I need to compute a curvature of a simple 2D discrete function like this one:
x=1:0.5:20;
y=exp(x);
can anybody help how to do that? thanks

Best Answer

You function seems to be a 1D function.
Are you looking for the 2nd derivative? While diff calculates the one-sided differential quotient, gradient uses the two-sided inside the interval:
gradient(gradient(y))
If you mean the curvature as reciprocal radius of the local fitting circle:
dx = gradient(x);
ddx = gradient(dx);
dy = gradient(y);
ddy = gradient(dy);
num = dx .* ddy - ddx .* dy;
denom = dx .* dx + dy .* dy;
denom = sqrt(denom);
denom = denom * denom * denom;
curvatur = num ./ denom;
curvature(denom < 0) = NaN;
Please test this, because I'm not sure if I remember the formulas correctly.
Related Question