How to add cost to a polygon?

조회 수: 1 (최근 30일)
SUSHMA MB
SUSHMA MB 2015년 4월 6일
편집: SUSHMA MB 2015년 4월 9일
I have coordinates of some polygons and they are stored in a cell, now i want to add cost to those, how can i do that? For ex: the coordinates of the polygons are [12.45 36.05; 12.45 35.7; 12.9 35.65; 12.9 36; 12.7 36; 12.7 36.1; 12.45 36.05] and similarly the coordinates of the other polygons are stored in a single cell. Now i want to add 500 as the cost of the polygon, how can i add?
I have stored the coordinates in x and y in a cell, now how to store the cost?

채택된 답변

Image Analyst
Image Analyst 2015년 4월 6일
You could have an array of structures - one structure for each polygon that stores the x, y, and cost as fields. For example, to assign the kth structure of the kth polygon:
polygons(k).x = yourXArray; % for that particular polygon.
polygons(k).y = yourYArray; % for that particular polygon.
polygons(k).cost = yourCostValue; % for that particular polygon.
  댓글 수: 2
SUSHMA MB
SUSHMA MB 2015년 4월 6일
How to access cost in this?
Image Analyst
Image Analyst 2015년 4월 6일
To get the cost of the kth polygon, just refer to it
theCost = polygons(k).cost;

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Elementary Polygons에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by