Help with date tick.

I have a set of data that needs to be plot for the period of time entered on the edit text cox in GUI.I would like to display date tick for every 10 mins starting from the start time entered and finish at the end time entered.Date are supposed to be entered in dd/mm/yyyy HH:MM format.
start_time = datenum(get(handles.edit1,'String'));
end_time = datenum(get(handles.edit3,'String'));
long = length(data);%data is the data file
eeg_t=linspace(start_time,end_time,long);%create a time vector for plot that matches the number of data points
bar(eeg_t,data)
How do I get x-axis ticked in HH:MM for every 10 mins. I have a long data set(6-7 hrs worth, and one data point every 30 seconds).
Thanks

1 comentario

Benjamin Kraus
Benjamin Kraus el 9 de Mayo de 2016
The basic command you are looking for is 'datetick'. By default 'datetick' will pick tick values that are not too close together, but if you want to force it to put a tick every 10 minutes you will have to specify the ticks and then use the 'keepticks' input when calling 'datetick'. For example:
start_time = datenum('May 9, 2016 10:00');
end_time = datenum('May 9, 2016 17:00');
tenmin = 10/24/60;
ticks = start_time:tenmin:end_time;
t = start_time:30/24/60/60:end_time;
y = sin(t*200);
plot(t,y);
set(gca,'XTick',ticks);
datetick('x','HH:MM','keepticks');
Because there is 7 hours of data, a tick every 10 minutes will mean the ticks are squeezed tightly together, but if you zoom in you will see that there is one tick every 10 minutes.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Etiquetas

Preguntada:

el 9 de Mayo de 2016

Editada:

el 5 de Jun. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by