load('driving_profiletest.mat');
drivingprofiletest.end_time(strcmp(drivingprofiletest.end_time,'00:00')) = {'23:59'};
drivingprofiletest = convertvars(drivingprofiletest, {'st_time', 'end_time'}, 'string');
ev_id = drivingprofiletest.hp_id;
distance = drivingprofiletest.distance;
realdistance = drivingprofiletest.realdistance;
st_time = drivingprofiletest.st_time;
end_time = drivingprofiletest.end_time;
occupation = drivingprofiletest.occupation;
housing = drivingprofiletest.housing;
carsize = drivingprofiletest.car_size;
state = drivingprofiletest.state;
regiostar = drivingprofiletest.regiostarGem7;
value = drivingprofiletest.realdistance;
t_End = datetime(drivingprofiletest.end_time,'InputFormat','HH:mm');
t_St = datetime(drivingprofiletest.st_time,'InputFormat','HH:mm');
tt_End = hour(t_End) + minute(t_End)/60;
tt_St = hour(t_St) + minute(t_St)/60;
drivingprofiletest.duration = tt_End - tt_St;
duration = drivingprofiletest.duration;
timediff = duration.*60;
singularvalue = value./timediff;
Tzeros_LSH = zeros(24*60+1,1);
traffic = zeros(24*60+1,1);
for i = 1:length(end_time)
[Y, M, D, H, MN, S] = datevec(st_time(i));
TrSt = H*60+MN+1;
[Y, M, D, H, MN, S] = datevec(end_time(i));
TrEn = H*60+MN+1;
if isnan(TrEn) || isnan(TrSt)
continue
else
Tzeros_LSH(TrSt:TrEn,1) = Tzeros_LSH(TrSt:TrEn,1) + 1;
traffic(TrSt:TrEn,1) = traffic(TrSt:TrEn,1) + singularvalue(i);
end
end
close all
t_min = 1:length(Tzeros_LSH);
t_hour = t_min/60;
figure
plot(t_hour,traffic)
xlim([1 24])
xlabel("Time (h)")
ylabel("Load shifting potential (kW)")
grid on