フィルターのクリア

How do I sum the elements of each corner of a matrix?

4 ビュー (過去 30 日間)
David
David 2020 年 2 月 23 日
回答済み: KSSV 2020 年 2 月 23 日
If I have a 4x4 matrix, how do i sum 4 elements in 4 corner of that matrix
for example my matrix will be : A=[1 2 3 4; 5 6 7 8 9;10 11 12 13; 14 15 16 17]
Thanks you so much
  1 件のコメント
Walter Roberson
Walter Roberson 2020 年 2 月 23 日
When you index with a list of values then what is selected is all the locations that meet all of the criteria. For example A([1 3],[2 4]) choses all the locations that are in row 1 or 3 and that are in columns 2 or 4. That would be a total of 4 locations.

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

採用された回答

KSSV
KSSV 2020 年 2 月 23 日
iwant = A(1,1)+A(1,end)+A(end,1)+A(end,end)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by