Restricting time on graph with given time
    2 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Sebastian Sunny
 el 26 de Nov. de 2021
  
    
    
    
    
    Comentada: dpb
      
      
 el 26 de Nov. de 2021
            Trying make a graph with given time data values for all of 2019 managed to plot the graphs but how do i restrict the graph to only plot january using the datetime function?
0 comentarios
Respuesta aceptada
  dpb
      
      
 el 26 de Nov. de 2021
        Alternatively, simply
xlim([datetime(2019,1,1) datetime(2019,1,31)])
will leave all the data plotted but only display that between the two dates selected for the axis limits.  This would let you simply reset those to change the visible portion without replotting each time.
Of course, if you want to look at the data and do something else with it (as almost certainly will if not yet), then groupsummary and rowfun will be your very best friends "realsoonnow™"
1 comentario
  dpb
      
      
 el 26 de Nov. de 2021
				Alternatively to the above, you might consider using a timetable going forward instead...then retime and friends are also in play...
Más respuestas (1)
  Chunru
      
      
 el 26 de Nov. de 2021
        a = datetime(2021, 1, 1:365);
b = rand(size(a));
plot(a, b)
idx = find(month(a)==1);
xlim([a(idx(1)), a(idx(end))])
0 comentarios
Ver también
Categorías
				Más información sobre Dates and Time en Help Center y File Exchange.
			
	Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



