Plot the timestamp versus data from excel file
1 view (last 30 days)
Show older comments
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=============================
0 Comments
Answers (1)
Mahesh Taparia
on 4 Oct 2019
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.
Hope it helps!
0 Comments
See Also
Categories
Find more on Data Import from MATLAB 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!