How to plot different markers on the same graph based on "if" statement
    1 visualización (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Jayden Yeo
 el 15 de Jun. de 2020
  
    
    
    
    
    Editada: Jayden Yeo
 el 6 de Dic. de 2020
            Hi,
I have a table of data as below. Based on "c", I would like to plot X and Y using 2 different markers.
i.e. if c="car", plot the X & Y coordinates using "o" type marker.
if c = "plane", plot the X & Y coordinates using "+" type marker.
My code as below:
if coordinates.c == "car"
     plot(coordinates.X,coordinates.Y,"ro")
else
    plot(coordinates.X,coordinates.Y,"b+")
end
 The codes above is not working. Matlab plots all the X & Y coordinates using the "+" type marker. 
Pls advise where is the issue. Thanks in advance  
0 comentarios
Respuesta aceptada
  KSSV
      
      
 el 15 de Jun. de 2020
        figure
hold on
idx = strcmp(c,'air') ; 
plot(x(idx),y(idx),'+r')
idx = strcmp(c,'land') ; 
plot(x(idx),y(idx),'+b')
Más respuestas (0)
Ver también
Categorías
				Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

