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.

2 ビュー (過去 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')
HABILA
HABILA 2019 年 7 月 15 日
This one worked perfect. Thank You so much.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGrid 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