Plot the timestamp versus data from excel file

2 次查看(过去 30 天)
I would like to plot the timestamp in the x-axis and the data in the y axis using plot command. I have written the below code to achieve this. But i have some issue.
1) As shown in the plot(Attached timestampplot.png) the starting timestamp 12:38:06:001 why doesn't start right at the origin? why the timestamps are not having equal intervals? why timestamp 12:38:06:003 is not visible although it has only 10 points?
2) How can i zoom in and see more resolution between two timestatmps?
=====Codestarts here===========================
[num,txt,raw] = xlsread('Test1.xlsx');
time = vertcat(txt{2:end,1}) ;
data = num(:,1) ;
starttime = datenum(time(1,:),'HH:MM:SS:FFF');
endtime = datenum(time(end,:),'HH:MM:SS:FFF');
xData = linspace(starttime,endtime,size(time,1));
plot(xData,data,'-*','color','g')
datetick('x','HH:MM:SS:FFF','keepticks','keeplimits');
=====Codeend here=============================

回答(1 个)

Mahesh Taparia
Mahesh Taparia 2019-10-4
Hi Suresh,
It looks like datetick function does not have a precision of millisecond while converting datenum object back to date format. May be that’s the reason of inconsistency in the graph.
Also, you can always normalize the data if you want the graph to start at origin.
You can refer to the prescribed date format in MATLAB.
Hope it helps!

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by