Plot the timestamp versus data from excel file

조회 수: 4 (최근 30일)
Suresh
Suresh 2019년 9월 25일
답변: Mahesh Taparia 2019년 10월 4일
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