MATLAB: Transfer hh:mm (Time) into “double”

hourminutetime

Hello,
I have written a program, that calculates the cheapest way to charge an EV based on dynamic elctricity prices. As an input the program uses the Arrival and Departure time of the user in 'double'. So if the vehicle arrives at "10:30 am" the arrival parameter is 10,5. It gets even more complicated if the arrival time is e.g. "10:31". The value should then be 10,5166666666….. This is quite cumbersome.
Is there any way to transfer "hh:mm" into a double value?
Greetings
Alex

Best Answer

>> str = '10:31';
>> val = [1,1/60]*sscanf(str,'%d:%d')
val = 10.51666666666667