Extracting time from timestamp

6 ビュー (過去 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 Center および File ExchangeWhos についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by