Converting and plotting serial number to time format [hh:mm]
조회 수: 1 (최근 30일)
이전 댓글 표시
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)
댓글 수: 0
답변 (1개)
Star Strider
2020년 11월 22일
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
Star Strider
2020년 11월 22일
My (our) pleasure!
If my Answer helped you solve your problem, please Accept it!
.
참고 항목
카테고리
Help Center 및 File Exchange에서 Calendar에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!