MATLAB: Matching columns of timetables

optimize codetimetable

I have two time tables: date_tt (261 X 7) and energy_tt (25056 X 5). The rowtimes in energy_tt is the date and time at 15 minute intervals for the year 2019 (excluding the weekends). The row times in date_tt each date of 2019(again excluding weekends). The fourth column in date_tt is of datetime format with the date of the corresponding rowtime and an assigned time.
Now, I have to match the datetime in energy_tt rowtimes with the datetimes in date_tt 4th column. For this i wrote the following code.
for i = 1:height(energy_tt)
for j = 1:height(date_tt)
if energy_tt.Properties.RowTimes(i) == date_tt.Start_time_1(j)
energy_tt.Power(i) = 11;
end
end
end
But given the large number of rows in both the timetables, the code takes a lot of time to run. Kindly suggest a way to optimize this code.

Best Answer

ix=ismember(energy_tt.RowTimes,date_tt.Start_time_1);
energy_tt.Power(ix) = 11;
Also see the synchronize function