Summation of every nth column
조회 수: 3 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (1개)
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
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.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!