How can I plot a filled convex shape?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Canberk Suat Gurel
el 25 de Feb. de 2018
Comentada: Image Analyst
el 25 de Feb. de 2018
Is it possible to plot a filled convex shape?
This is what I want to plot:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/170759/image.jpeg)
This is what I have plotted using the rectangle command but it does not work with unordinary shapes.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/170760/image.jpeg)
0 comentarios
Respuesta aceptada
Star Strider
el 25 de Feb. de 2018
This works for me with both fill and patch in R2017b:
x = [120 158 165 188 198 145];
y = [ 55 51 89 51 14 14];
figure(1)
fill(x, y, [0.1 0.5 0.9])
axis([100 200 0 150])
axis equal
figure(2)
patch(x, y, [0.1 0.5 0.9])
axis([100 200 0 150])
axis equal
The patch function usually closes the curve on its own. If it doesn’t, close it yourself:
patch([x x(1)], [y y(1)], [0.1 0.5 0.9])
0 comentarios
Más respuestas (1)
Image Analyst
el 25 de Feb. de 2018
For analytical data (graph points) you can do what Star says.
If you have digital images, look at the functions imfill(), bwconvhull(), and poly2mask(). They're all slightly different depending on what you're starting with and what you want to end up with.
1 comentario
Image Analyst
el 25 de Feb. de 2018
I don't think Canberk cares about your question - it doesn't answer or address his problem at all - so post your question in a new, completely separate post, not here.
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!