How to plot the elements of a matrix with a specific coordinates and specified the region in matlab?

2 ビュー (過去 30 日間)
Hello everybody. I need your help about a problem that I have in matlab.
For instance lets say that I have a Matrix X = [1,2,3,4,5,6,7,8] with different coordianates as shown above. For example, Element 1 of the matrix = (0,1).
And, I would like to set the regions as shown in below.
Is it possibles to create something like this?
Thank you in advance.
  2 件のコメント
darova
darova 2019 年 10 月 29 日
  • And, I would like to set the regions as shown in below.
You want to paint regions in different color?
Mavis Lee
Mavis Lee 2019 年 10 月 29 日
編集済み: Mavis Lee 2019 年 10 月 29 日
Hi Darova.
It's ok with or without the color.
I just want to set few regions inside the Circle. For example, the region 1 (yellow color) is located within 1, 5 and 2 as shown in figure below.
It is possible to set the region using the coordinates of point 1, 5 and 2 or have other better solution?
Thank you in advance.

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

採用された回答

darova
darova 2019 年 10 月 29 日
Maybe inpolygon
n = 100;
t = -linspace(0,2*pi,n)+pi/2;
x = cos(t);
y = sin(t);
x0 = 0.5; % point to check
y0 = 0.7;
nd = 8; % divide circle in 8 parts
for i = 1:nd
ii = (i-1)*n/nd+1 : i*n/nd;
ii = round(ii);
if inpolygon(x0,y0,[x 0],[y -11]) % segment of a circle and (0,-1) point
sprintf('point in R%d region',i)
end
end
  3 件のコメント
darova
darova 2019 年 10 月 29 日
My bed, sorry
clc,clear
n = 100;
t = -linspace(0,2*pi,n)+pi/2;
x = cos(t);
y = sin(t);
x0 = 0.5; % point to check
y0 = 0.2;
nd = 8; % divide circle in 8 parts
cla
plot(x,y,'.b')
hold on
plot(x0,y0,'or')
i1 = 1; % start index of a section
for i = 1:nd
i2 = round(i*n/nd); % end index of a section
xx = [x(i1:i2) 0]; % region of interest
yy = [y(i1:i2) -1];
p = patch(xx,yy,'','FaceCOlor',rand(1,3));
if inpolygon(x0,y0,xx,yy) % segment of a circle and (0,-1) point
sprintf('point is in R%d region',i)
plot(x0,y0,'or')
end
pause(0.5)
% delete(p)
i1 = i2;
end
hold off
Mavis Lee
Mavis Lee 2019 年 10 月 29 日
Hi Darova,
Thank you so much for helping ^_^

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by