I have 100 data scattered across 100 X 100 size plot. I need to partition the plot into four sub-sections across the center. Can anyone help me.

1 次查看(过去 30 天)
close all
clear
clc
n=100
for h=1:1
for i=1:1:n
if(i<=25)
S(i).xd=randi([0,40]);
S(i).yd=randi([0,40]);
end
if((i>25)&&(i<=50))
S(i).xd=randi([60,100]);
S(i).yd=randi([0,40]);
end
if((i>50)&&(i<=75))
S(i).xd=randi([0,40]);
S(i).yd=randi([60,100]);
end
if(i>75)
S(i).xd=randi([60,100]);
S(i).yd=randi([60,100]);
end
XR(i)=S(i).xd;
YR(i)=S(i).yd;
figure(1)
plot(XR(i),YR(i),'kp','MarkerSize', 8);
drawnow;
hold on;
end
end

采纳的回答

Stephan
Stephan 2019-7-14
starting from R2018b you can use xline and yline:
close all
clear
clc
n=100
hold on
for h=1:1
for i=1:1:n
if(i<=25)
S(i).xd=randi([0,40]);
S(i).yd=randi([0,40]);
end
if((i>25)&&(i<=50))
S(i).xd=randi([60,100]);
S(i).yd=randi([0,40]);
end
if((i>50)&&(i<=75))
S(i).xd=randi([0,40]);
S(i).yd=randi([60,100]);
end
if(i>75)
S(i).xd=randi([60,100]);
S(i).yd=randi([60,100]);
end
XR(i)=S(i).xd;
YR(i)=S(i).yd;
figure(1)
plot(XR(i),YR(i),'kp','MarkerSize', 8);
drawnow;
end
end
xline(50);
yline(50);
hold off
  3 个评论
Stephan
Stephan 2019-7-14
编辑:Stephan 2019-7-14
then build them by hand:
x_line = [50 50; 0 100];
y_line = [0 100; 50 50];
plot(x_line(1,:),y_line(1,:),'k')
plot(x_line(2,:),y_line(2,:),'k')

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Grid Lines, Tick Values, and Labels 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by