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 vue (au cours des 30 derniers jours)
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

Réponse acceptée

Stephan
Stephan le 14 Juil 2019
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 commentaires
Stephan
Stephan le 14 Juil 2019
Modifié(e) : Stephan le 14 Juil 2019
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')

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by