how to extract previous week and month number of same hour?
3 views (last 30 days)
I had load data of one year, half houly data of load (1*17520), I want to add a column having load data of previous week (same day & time period) and another column having previous day data at same time slot
We can keep blank for initial week/day data because for that previous data is not available here.
Sujay C Sharma on 17 Jun 2020
Since the number of load entries per day is fixed at 48 (half-hourly data), this can be done using the circshift function on the load column in your data. Here is an example of how you can use circshift to achieve what you want:
X = readtable('Book1.xlsx');
NumEntriesPerDay = 48;
Data = X.load;
DataPrevDay = circshift(data,NumEntriesPerDay*1);
DataPrevDay(1:NumEntriesPerDay*1) = NaN;
DataPrevWeek = circshift(data,NumEntriesPerDay*7);
DataPrevWeek(1:NumEntriesPerDay*7) = NaN;
X.PreDayload = DataPrevDay;
X.PrevWeekLoad = DataPrevWeek;