Extracting time from timestamp

조회 수: 2 (최근 30일)
Manas Pratap
Manas Pratap 2021년 11월 6일
답변: Star Strider 2021년 11월 6일
I have a dataset that looks like this (a csv file)
I need to plot temperature of 5 days vs time (in hours)
I seem to be stuck on trying to extract the time in hours from the timestamp. I HAVE TRIED using "hours" but if you observe carefully, if i just use hours, then what happens is that under the hour "14" both entries of "14:00" and "14:30" come, essentially, 2 datavalues for 1 datapoint. This is creating a nightmare graph for me
Any help is greatly appreciated.
x = humidity_site1;
hday1 = x(674:721);
hday2 = x(722:769);
hday3 = x(770:817);
hday4 = x(818:865);
hday5 = x(866:913);
tday1 = hour(y(675:722));
tday2 = hour(y(722:769));
tday3 = hour(y(770:817));
tday4 = hour(y(818:865));
tday5 = hour(y(866:913));
plot(tday1,hday1,tday2,hday2,tday3,hday3,tday4,hday4,tday5,hday5)
legend('Mar 15','Mar 16','Mar 17','Mar 18','Mar 19');
figure
plot(tday1,hday1)
%I imported the data as separate column vectors using the "Import Data"
%tool

채택된 답변

Star Strider
Star Strider 2021년 11월 6일
See my Answer to the essential duplicate of this Extracting time from datetime
With respect to eliminating the connecting lines, sort the data by the x-coordinate. That should elimiinate them.
Meanwhile, as I explained in the post I referenced, I cannot do anything until I have at least an example of that file, and the MATLAB release/version being used to read and plot it (since there have been significant differences over the past decade).
.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by