- And, I would like to set the regions as shown in below.
How to plot the elements of a matrix with a specific coordinates and specified the region in matlab?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mavis Lee
am 29 Okt. 2019
Kommentiert: Mavis Lee
am 29 Okt. 2019
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
am 29 Okt. 2019
You want to paint regions in different color?
Akzeptierte Antwort
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
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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!