Plot the timestamp versus data from excel file

1 Ansicht (letzte 30 Tage)
Suresh
Suresh am 25 Sep. 2019
Beantwortet: Mahesh Taparia am 4 Okt. 2019
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=============================

Antworten (1)

Mahesh Taparia
Mahesh Taparia am 4 Okt. 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.
You can refer to the prescribed date format in MATLAB.
Hope it helps!

Kategorien

Mehr zu Data Import from MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by