Converting and plotting serial number to time format [hh:mm]

1 view (last 30 days)
I have a data with client number and parking time for EV charging station.The data is loaded in xlsx format. Please find the below attached parking time data sample.
Parking time data sample:
7:05:55 AM
12:41:02 AM
12:38:50 AM
When i clear formats in excel , it becomes
0.295775463
0.02849537
0.026967593
When i use this data for plotting as bar graph (parking time against the cleint number)in matlab , it shows the serial number format.Below is the code i have used.Kindly help to make it appear in 24 hour time format (Parkingtime[hh:mm] in y axis.
z=xlsread('time.xlsx');
parkingtime=z((1:end),4);
clientnumber=z((1:end),1);
parkingtime = parkingtime.';
bar(clientnumber,parkingtime)

Answers (1)

Star Strider
Star Strider on 22 Nov 2020
Ideally, there should be a date as well.
In the interim:
t = [0.295775463
0.02849537
0.026967593];
DT1 = datetime(t, 'ConvertFrom','excel', 'Format','HH:mm')
produces:
DT1 =
3×1 datetime array
07:05
00:41
00:38
This converts the times appropriately. Make appropriate changes to the 'Format' property to get the result you want.
(The date values need to be supplied, since I seriously doubt there were abundant EV charging stations in 1899.)
  4 Comments
Star Strider
Star Strider on 22 Nov 2020
My (our) pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Sign in to comment.

Categories

Find more on Dates and Time in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!