Extracting elements common to rows and columns in a matrix

If I have a 5x6 matrix for example, how can I go about extracting elements common to the 3rd and 5th rows & the 4th and 5th columns?

 採用された回答

James Tursa
James Tursa 2020 年 11 月 10 日
編集済み: James Tursa 2020 年 11 月 10 日

0 投票

M = your matrix
result = M([3,5],4:5)
The [3,5] syntax is simply a vector with the indexes specified in any order. They don't have to be contiguous or increasing and can even repeat or decrease if you want.
The 4:5 syntax is a vector of contiguous indexes between the first number and the second number. E.g.,
4:5 is the same as [4,5]
2:6 is the same as [2,3,4,5,6]
etc.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

質問済み:

AD
2020 年 11 月 10 日

編集済み:

2020 年 11 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by