Borrar filtros
Borrar filtros

How can I set the format HH:MM to plot an array?

5 visualizaciones (últimos 30 días)
Eric Bernard Dilger
Eric Bernard Dilger el 22 de Jul. de 2021
Comentada: Eric Bernard Dilger el 22 de Jul. de 2021
I'm generating some arrays to represent the irradiance fluctuations along the day. The fluctuations about 3pm are smaller than the fluctuations during the midday and I want to show the difference. So I'm able to generate the irradiance data, but I'm having some trouble to set the time format on the x axis. I'm using this script to plot the figure below:
figure
plot(point) % Irradiance fluctuation (blue plot)
hold
plot(G_dir,'--','LineWidth',2,'Color','y')
plot(G_dif,'LineWidth',2,'Color','g')
plot(G_dir + G_dif,'LineWidth',2,'Color','r')
The algorithm generates 3500 samples for each signal (one sample per second). The signals are generate by a for loop (for t = 1 : 3500). I want the x axis to be represent in HH:MM format and I also the start time to be 15:00 and the end time to be 15:58. I appreciate any help.

Respuesta aceptada

Chunru
Chunru el 22 de Jul. de 2021
Editada: Chunru el 22 de Jul. de 2021
t = datetime(0,0,0,15,0,1:3500); % Y,M,D,HH,MM,SS
x = randn(3500, 1);
plot(t, x)
datetick('x', 'HH:MM')
xlim(t([1 end]))
  1 comentario
Eric Bernard Dilger
Eric Bernard Dilger el 22 de Jul. de 2021
Thank you @Chunru. It works very well for my application! I was trying something similar to the solution reported by you, but I wasn't understanding how to define the inicial time and the duration for the datetime function. Thank you very much!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Spectral Measurements 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!

Translated by