multiplying certain parts of an 8x8 matrix

How do I sum the 4 corners and 4 middle numbers of an 8x8 magic matrix?

1 件のコメント

Jan
Jan 2011 年 1 月 29 日
You mention a mutliplication in the subject, but ask for a sum in the body.

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

回答 (2 件)

Matt Fig
Matt Fig 2011 年 1 月 28 日

2 投票

M = magic(8)
S = sum(M([1 8 57 64 28 29 36 37]))

1 件のコメント

Jan
Jan 2011 年 1 月 29 日
You can get this solution if you look on: reshape(1:64, 8, 8)

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

Walter Roberson
Walter Roberson 2011 年 1 月 28 日

0 投票

sum( [M(1,1), M(1,end), M(end,1), M(end,end), reshape(M(floor(end/2):floor(end/2)+1,floor(end/2):floor(end/2)+1),1,[]) ])

カテゴリ

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

タグ

質問済み:

2011 年 1 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by