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

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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Two y-axis에 대해 자세히 알아보기

태그

질문:

2016년 5월 9일

편집:

2016년 6월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by