How can I make a plot with the date and time on the x-axis?
2 views (last 30 days)
Show older comments
I have imported some data into Matlap. One of the vectors is date and time (ex 19.12.2013 11:56:22). Matlab have made all date formatted cells into Matlab serial date number format. How can I plot my sound power vector aginst the date-time vector? I would like the date-time on the x-axis(not the date number) and the sound power on the y-axis. I have included a small file with some of my data.
0 Comments
Answers (1)
Azzi Abdelmalek
on 3 Jan 2014
[~,~,v]=xlsread('data.xlsx')
v=v(2:end,:);
x=datenum(v(:,1),'dd/mm/yyyy HH:MM:SS')
y=cell2mat(v(:,2))
[idx,idx]=sortrows([x,y])
plot(x(idx),y(idx))
xticks=get(gca,'Xtick')
set(gca,'xticklabel',datestr(xticks,'dd/mm/yyyy HH:MM:SS'))
8 Comments
See Also
Categories
Find more on Time Series Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!