how to extract previous week and month number of same hour?

4 ビュー (過去 30 日間)
MUKESH KUMAR
MUKESH KUMAR 2020 年 6 月 16 日
コメント済み: Nada Mounir 2022 年 2 月 28 日
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.
  5 件のコメント
MUKESH KUMAR
MUKESH KUMAR 2020 年 6 月 16 日
Ok sure
Steven Lord
Steven Lord 2020 年 6 月 17 日
KSSV: if MUKESH KUMAR has the date and time data stored as a datetime array or as the time vector in a timetable, there's no need to split that data to jump backwards a day or a week.
d = datetime('now')
dMinusWeek = d - calweeks(1)
dMinusDay = d - caldays(1)

サインインしてコメントする。

採用された回答

Sujay C Sharma
Sujay C Sharma 2020 年 6 月 17 日
Hi,
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;
  2 件のコメント
MUKESH KUMAR
MUKESH KUMAR 2020 年 6 月 18 日
thanks
Nada Mounir
Nada Mounir 2022 年 2 月 28 日
Please it doesn't work for me i have the same problem

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by