フィルターのクリア

curvature of a discrete function

84 ビュー (過去 30 日間)
David Kusnirak
David Kusnirak 2013 年 1 月 16 日
編集済み: Jan 2022 年 3 月 13 日
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
  1 件のコメント
Matt J
Matt J 2013 年 1 月 16 日
Your function looks 1D to me.

サインインしてコメントする。

採用された回答

Jan
Jan 2013 年 1 月 16 日
編集済み: Jan 2022 年 3 月 13 日
Your 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) .^ 3;
curvature = num ./ denom;
curvature(denom < 0) = NaN;
Please test this, because I'm not sure if I remember the formulas correctly.
  3 件のコメント
Jan
Jan 2013 年 1 月 16 日
編集済み: Jan 2013 年 1 月 16 日
Therefore I'm using an efficient C-Mex function: FEX: DGradient, which is 10 to 20 times faster and handles unevenly spaced data more accurate.
Jan
Jan 2013 年 1 月 16 日
編集済み: Jan 2022 年 3 月 13 日
x = rand(1, 1e6);
tic; ddx = gradient(gradient(x)); toc
tic; ddx = DGradient(DGradient(x)); toc
tic; ddx = conv(x,[.25 0 -.5 0 .25],'same'); toc
Elapsed time is 0.251547 seconds.
Elapsed time is 0.025728 seconds.
Elapsed time is 0.028208 seconds
Matlab 2009a/64, Core2Duo, Win7

サインインしてコメントする。

その他の回答 (2 件)

Roger Stafford
Roger Stafford 2013 年 1 月 16 日
編集済み: Bruno Luong 2022 年 3 月 13 日
Let (x1,y1), (x2,y2), and (x3,y3) be three successive points on your curve. The curvature of a circle drawn through them is simply four times the area of the triangle formed by the three points divided by the product of its three sides. Using the coordinates of the points this is given by:
K = 2*abs((x2-x1).*(y3-y1)-(x3-x1).*(y2-y1)) ./ ...
sqrt(((x2-x1).^2+(y2-y1).^2).*((x3-x1).^2+(y3-y1).^2).*((x3-x2).^2+(y3-y2).^2));
You can consider this as an approximation to the curve's curvature at the middle point of the three points.
  2 件のコメント
Jan
Jan 2013 年 1 月 16 日
Moreno, M.
Moreno, M. 2022 年 3 月 13 日
編集済み: Jan 2022 年 3 月 13 日

サインインしてコメントする。


Matt J
Matt J 2013 年 1 月 16 日
編集済み: Matt J 2013 年 1 月 16 日
diff(y,2)./0.5^2

カテゴリ

Help Center および File ExchangeAuthor Block Masks についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by