i would like to ask how to plot coordinate by looping
this is beause i have some "status" to be followed when plotting,
thus im using the loop to check the status (4th column) like below:-
if it equal to 1 the marker should be in -*
if it equal to 0 the marker should be in -o red color
if none of the above, it should draw line,
but i only got the marker type only, not the "else" part
how should i able to plot the line and different type of marker base on the status at the 4th column
cities6=[181 -12 70 2
56 -12 80 1
184 -12 90 2
185 -12 100 2
186 -12 110 2
187 -4 110 2
188 0 110 2
189 4 110 2
4 8 110 0];
xa6=cities6(:,2);
ya6=cities6(:,3);
noofcities6=cities6(:,1);
for s6=1:n6
status6=cities6(:,4);
labels6=cellstr(num2str(noofcities6(s6)));
if status6(s6) == 1,
plot(xa6(s6),ya6(s6),'-*');
text(xa6(s6),ya6(s6),labels6, 'VerticalAlignment','bottom','HorizontalAlignment','right');
hold on
end
if status6(s6) == 0,
plot(xa6(s6),ya6(s6),'-o','color','r');
text(xa6(s6),ya6(s6),labels6, 'VerticalAlignment','bottom','HorizontalAlignment','right','color','r');
hold on
else
plot(xa6(s6),ya6(s6),'-');
end
hold on
end
grid on
grid minor
Thank you.

 Réponse acceptée

Thorsten
Thorsten le 22 Oct 2015
Modifié(e) : Thorsten le 22 Oct 2015

0 votes

The points are not visible because plot(xa6(s6),ya6(s6),'-'); just plots a single point that falls on the axis or the grid lines. Use
axis([-20 10 50 120])
grid off
or
plot(xa6(s6),ya6(s6),'x');

3 commentaires

nadhirah
nadhirah le 22 Oct 2015
hi Thorsten, thanks for answering, i have tried your suggestion, i manage to plot the point but can't display the line connected between the points, i tried '-x' and grid off, it display x as marker, but no line.
Thorsten
Thorsten le 22 Oct 2015
You see no line because you plot only a single point in each plot command. To plot the line, use
plot(xa6, ya6, '-')
nadhirah
nadhirah le 23 Oct 2015
now i know why, thank you =)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Line Plots dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by