Filter löschen
Filter löschen

Matching columns of timetables

2 Ansichten (letzte 30 Tage)
vidit kedia
vidit kedia am 29 Jan. 2021
Beantwortet: dpb am 29 Jan. 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.

Akzeptierte Antwort

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

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with Optimization Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by