how to use polyarea

조회 수: 12 (최근 30일)
louis rassinfosse
louis rassinfosse 2016년 4월 28일
댓글: louis rassinfosse 2016년 4월 29일
hello,
I would need some help using the 'polyarea' function..
lets say: x=[1.5 1.25]; y=[570 363];
Plot(x,y) gives me a clear line, when is use area(x,y) I can visualize the area I want to calculate, but when I use polyarea(x,y), the answer is always 0 ... Can anyone help me out ?
  댓글 수: 1
John D'Errico
John D'Errico 2016년 4월 28일
What area is it that you want to calculate? Be clear, as it is difficult for us to know what you are visualizing. The crystal ball can be so foggy.
For example, what if the line crosses the x-axis?

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2016년 4월 29일
You need at least 3 points to have an area. Maybe you want the area below. Try this:
x=[1.5 1.25];
y=[570 363];
xTrap = [x(1), x(1), x(2), x(2)]
yTrap = [0, y(1), y(2), 0]
patch(xTrap, yTrap, 'r.-', 'LineWidth', 2);
grid on;
theArea = polyarea(xTrap, yTrap)
  댓글 수: 1
louis rassinfosse
louis rassinfosse 2016년 4월 29일
Thank you very much for the fast response! It was indeed that area a wanted to figure out!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Computational Geometry에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by