フィルターのクリア

How do I find polygonal curve length?

6 ビュー (過去 30 日間)
Jim Oste
Jim Oste 2015 年 2 月 8 日
コメント済み: Image Analyst 2015 年 2 月 11 日
My problem is to write a function to compute the length of a polygonal curve whose ith vertex has Cartesian coordinates x(i) and y(i). x and y must be row or column vectors of the same size.

採用された回答

Image Analyst
Image Analyst 2015 年 2 月 8 日
Can't you use the Pythagorean theorem:
% Some data... however you got it.
x = rand(1, 5);
y = rand(1, 5);
% Get delta x and delta y.
dx = abs([diff(x), x(end)-x(1)])
dy = abs([diff(y), y(end)-y(1)])
% Find distances between vertices
distancesBetweenVertices = sqrt(dx.^2 + dy.^2)
% Sum all the sides to get the total perimeter.
perimeter = sum(distancesBetweenVertices)
  2 件のコメント
Jim Oste
Jim Oste 2015 年 2 月 11 日
How would I go about finding the x and y coordinates of a given function?
Image Analyst
Image Analyst 2015 年 2 月 11 日
You can write a couple of lines of code. For example to find x and y for a quadratic function between x=-5 and 5, with 31 coordinates, do this:
x = linspace(-5, 5, 31);
y = a * x.^2 + b * x + c; % You define a, b, anc c before this.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeComputational Geometry についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by