Matching columns of timetables

2 次查看(过去 30 天)
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.

采纳的回答

dpb
dpb 2021-1-29
ix=ismember(energy_tt.RowTimes,date_tt.Start_time_1);
energy_tt.Power(ix) = 11;
Also see the synchronize function

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with Optimization Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by