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 件のコメント

Benjamin Kraus
Benjamin Kraus 2016 年 5 月 9 日
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 ExchangeTwo 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