How to do a Matrix Aggregation.

I have 19720 of (7by7) matrices stacked up in excel file ( so basically a total of 138040 row). I want to aggregate these matrices into one (7by7) matrix where each row element represents the sum of all the elements in the rows from each (7by7) matrix. Any suggestions, please.

回答 (1 件)

Matt J
Matt J 2016 年 5 月 23 日

0 投票

Once you've read your data into a 138040x7 matrix, A
aggregation =sum( reshape(A.',7,7,[]) ,3).' ;

4 件のコメント

Amine Ben Ayara
Amine Ben Ayara 2016 年 5 月 23 日
編集済み: Matt J 2016 年 5 月 23 日
Hey Matt, I tried to run the code as you instructed, and I got this error message.
"aggregation =sum( reshape(Period1.',7,7,[]) ,3).' ;
Error using reshape
Product of known dimensions, 49, not divisible into total number of elements, 966273.
Matt J
Matt J 2016 年 5 月 23 日
編集済み: Matt J 2016 年 5 月 23 日
MATLAB is saying that you read only 966273 elements into Period1, but you should have 7 more,
>> 138040*7
ans =
966280
Amine Ben Ayara
Amine Ben Ayara 2016 年 5 月 26 日
Please look at the screen shot that I have from my Matlab workspace. So my input matrix is
Matt J
Matt J 2016 年 5 月 27 日
I have looked at it. It confirms what I said. You said you have 138040 rows, but the screenshot shows only 138039.

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

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

製品

質問済み:

2016 年 5 月 23 日

コメント済み:

2016 年 5 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by