フィルターのクリア

How can I turn a matrix into several submatrices and add up certain submarices?

2 ビュー (過去 30 日間)
Paul Wolfram
Paul Wolfram 2017 年 9 月 3 日
編集済み: Paul Wolfram 2017 年 9 月 3 日
Hi community,
I am wondering how to turn a large matrix (9800x9800) into 49x49 submatrices (each with 200x200 cells). Following that, I want to do the following operations:
  1. sum up all matrices on the diagonale
  2. sum up all matrices in the lower triangle
  3. sum up all matrices in the upper triangle
I have been succesful with the first item using the following code:
for i = 1 : meta.NCOUNTRIES;
i
Z_all{i} = Z((i - 1) * meta.NSECTORS + 1 : i * meta.NSECTORS, (i - 1) * meta.NSECTORS + 1 : i * meta.NSECTORS);
end
Z_RoW = zeros(meta.NSECTORS);
for i = 1 : meta.NCOUNTRIES;
i
Z_RoW = Z_RoW + Z_all{i};
end
where
  • meta.NCOUNTRIES = 49
  • meta.NSECTORS = 200
  • meta.Zdim = 9800
I think the above code is not ideal, i.e. it could be done w/o having to use a loop. Also, I have troubles with finding and summing up the elements in the lower/upper triangle.
Thank you!

回答 (1 件)

Image Analyst
Image Analyst 2017 年 9 月 3 日
  1 件のコメント
Paul Wolfram
Paul Wolfram 2017 年 9 月 3 日
編集済み: Paul Wolfram 2017 年 9 月 3 日
Hi Image Analyst,
this is nice for splitting up the matrix. I am still unsure though how to add up certain matrices, e.g. only the matrices in the lower or upper triangle (as shown in yellow shades / green shades in the picture below).
Thank you!

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

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by