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

3 次查看(过去 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 个评论
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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by