How do I read (hours) data from the .xlsx file?

5 views (last 30 days)
Hello,
I have the following issue. In a .xlsx file I have in column D hours (format: 00: 00: 00,01: 00: 00, ... 23:00:00). How can I integrate (read) them into the code to use them to plot some graphics I want. Your help is important.

Accepted Answer

Walter Roberson
Walter Roberson on 10 Feb 2021
[~,~,ALL_Data]=xlsread('Hours_Data.xlsx');
Hours = days(cell2mat(ALL_Data(2:25,end)));
Hours.Format = 'hh:mm';
Hours
Hours = 24×1 duration array
00:00 01:00 02:00 03:00 04:00 05:00 06:00 07:00 08:00 09:00 10:00 11:00 12:00 13:00 14:00 15:00 16:00 17:00 18:00 19:00 20:00 21:00 22:00 23:00
%OR
ALL_Data = readtable('Hours_Data.xlsx');
Hours = days(ALL_Data{:,end});
Hours.Format = 'hh:mm';
Hours
Hours = 24×1 duration array
00:00 01:00 02:00 03:00 04:00 05:00 06:00 07:00 08:00 09:00 10:00 11:00 12:00 13:00 14:00 15:00 16:00 17:00 18:00 19:00 20:00 21:00 22:00 23:00
  1 Comment
stelios loizidis
stelios loizidis on 10 Feb 2021
It works. Thank you very much for the valuable help !!!

Sign in to comment.

More Answers (1)

KSSV
KSSV on 10 Feb 2021
Read about readtable. In here after reading your specify the format of time. Have a look on duration.
  7 Comments

Sign in to comment.

Categories

Find more on Data Import from MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!