Help with reading and plotting date string
12 ビュー (過去 30 日間)
古いコメントを表示
I'm reading dates from an excel sheet using matlab. Matlab writes the data as '22/01/2015 13:30:00' '22/01/2015 14:00:00' '22/01/2015 14:30:00' '22/01/2015 15:00:00' '22/01/2015 15:30:00' '22/01/2015 16:00:00' '22/01/2015 16:30:00' '22/01/2015 17:00:00' '22/01/2015 17:30:00' '22/01/2015 18:00:00' '22/01/2015 18:30:00' '22/01/2015 19:00:00' '22/01/2015 19:30:00' '22/01/2015 20:00:00' '22/01/2015 20:30:00' '22/01/2015 21:00:00' '22/01/2015 21:30:00'
I would like use this date on the x-axis and to make a plot with a variable in y-axis.
Can any one help me how to make a plot with this date data. Thanks Venki
0 件のコメント
回答 (3 件)
Jos (10584)
2016 年 3 月 1 日
Convert the dates (in variable D), using DATENUM, plot, and use DATETICK to set the x-ticks to a specific format
plot(datenum(D), YVALUES)
datetick('x',31) % or any other format
Florian
2016 年 3 月 1 日
Use x = datenum( dates,'dd/mm/yyyy HH:MM:SS') to convert your strings to the internal matlab date number. Plot your x y data normally and use datetick('x',dateFormat) to format your x-axis. See http://ch.mathworks.com/help/matlab/ref/datetick.html
Regards, Florian
2 件のコメント
Jos (10584)
2016 年 3 月 1 日
Did you try? DATENUM seems to ignore quote marks
datenum('''22/02/16 13:02:34''')
Jan
2016 年 3 月 1 日
You can convert the shown cell string useing datenum and use datetick to display the dates as tick lables.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Time Series Objects についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!