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

3 Ansichten (letzte 30 Tage)
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 Kommentare
darova
darova am 29 Okt. 2019
  • And, I would like to set the regions as shown in below.
You want to paint regions in different color?
Mavis Lee
Mavis Lee am 29 Okt. 2019
Bearbeitet: Mavis Lee am 29 Okt. 2019
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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

darova
darova am 29 Okt. 2019
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 Kommentare
darova
darova am 29 Okt. 2019
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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by