Matching columns of timetables

2 visualizaciones (últimos 30 días)
vidit kedia
vidit kedia el 29 de En. de 2021
Respondida: dpb el 29 de En. de 2021
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.

Respuesta aceptada

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

Más respuestas (0)

Categorías

Más información sobre Get Started with Optimization Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by