How Can I modify the fill command?

Is there another MATLAB command like fill. If I utilize this command the output is not what I'm looking for. I want the area inside these coordinates value.
fill(coord_x, coord_y, 'r')
The code connects the points not in the way I want. Is there any other command?

1 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 2 月 25 日
What is the way you want?

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

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 2 月 25 日
編集済み: Azzi Abdelmalek 2014 年 2 月 25 日

1 投票

Maybe your coordinates are not correct. Look at this example
fill([0 1 1 0 0],[0 0 1 1 0],'r')
xlim([-2 2])

9 件のコメント

Francesco
Francesco 2014 年 2 月 25 日
My coordinates are theese one:
>> coord_estratte_x
coord_estratte_x =
32.5000
32.5000
37.0000
37.5000
>> coord_estratte_y
coord_estratte_y =
17.5000
13.7500
16.0000
15.0000
But I want the area inside these coordinates. It connets the points not in the correct way.
Francesco
Francesco 2014 年 2 月 25 日
The code does not know the order in which they must connect the points because it doesn't Know the area inside I want. I Know the order, the code no!
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 2 月 25 日
What is the correct way? we can't guess
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 2 月 25 日
Maybe you need to change your coordinates like
coord_x =[ 32.5000 32.5000 37.0000 37.5000]
coord_y =[17.5000 13.7500 15.0000 16.0000]
fill(coord_x, coord_y, 'r')
Francesco
Francesco 2014 年 2 月 25 日
Yes It's good. I have just thought something like this but it's not general code. In this case it's ok, but I have to do a general code: this is the problem. The area command is like fill and the code do the same thing. Is there any other command?
Image Analyst
Image Analyst 2014 年 2 月 25 日
Try patch().
Francesco
Francesco 2014 年 2 月 25 日
Azzi, I voted your questions because you are fine and polite. The questions is:
1) If I have some points How can I color the area enclosed by the outer segments?
Francesco
Francesco 2014 年 2 月 25 日
Image the patch command do the same! :
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 2 月 25 日
Francesco, thanks for your remarks, but accepting an answer means your problem is solved, you can vote an answer, but don't accept it until it helps you,
Try this
coord_x =[ 32.5000 32.5000 37.0000 37.5000]
coord_y =[17.5000 13.7500 16.0000 15.0000]
[idx,idx]=sort(coord_y)
fill(coord_x(idx), coord_y(idx), 'r')

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2014 年 2 月 25 日

0 投票

Find the centroid of the points. Then sort all of the points according to their polar angle relative to the centroid. If you sortrows() of the angle and the radius and then you reverse the order then it will be counter-clockwise and largest radius first, which happens to be one of the better ways of creating polygons.

カテゴリ

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by