フィルターのクリア

Summation of every nth column

1 回表示 (過去 30 日間)
Adnan Jayyousi
Adnan Jayyousi 2022 年 6 月 17 日
コメント済み: Jan 2022 年 6 月 19 日
Hello everyone,
I've imported xlsx file containing some data related to energy consumption, It was sampled in 15 minutes rate.
I want to convert this table to hourly values, in order to make hourly values I need to sum every 4 columns and store that data in a new matrix that sizes [8760x1], I want all the data be in series (just one column).
The data are for full year, so i expect to get 8760 (hours in a year) rows , and 1 column.
Thanks in advance.

回答 (1 件)

Jan
Jan 2022 年 6 月 17 日
編集済み: Jan 2022 年 6 月 17 日
S = size(LoadProfile);
X = reshape(LoadProfile, S(1), 4, S(2) / 4);
X = reshape(sum(X, 2), S(1), S(2) / 4).';
Result = X(:);
  2 件のコメント
Adnan Jayyousi
Adnan Jayyousi 2022 年 6 月 17 日
Hey Jan,
Thanks for your reply,
It works, there's little fix that i needed to make, because I wanted that all the data fit in one column
i.e 8760 Rows :)
Any way, this is the correction and it works fine (think so) :)
%%
S = size(LoadProfile);
X = reshape(LoadProfile, S(1), 4, S(2) / 4);
X = reshape(sum(X, 2), S(1), S(2) / 4).';
Result = X(1,:); %% Fit into 1 column
Result = Result' %% Transpose
%%
Thanks !
Jan
Jan 2022 年 6 月 19 日
Are you sure? This
Result = X(1,:)
crops the first row from the matrix X. My code uses X(:) to convert all elements of X into a column.

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

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by