How can I find a number from a matrix, which is greater than and closest to 1.

How can I find a number from a matrix, which is greater than and closest to 1. As I showed in attached table as an example. I know about indexing that just specifying the row and coloum I can find, however, if I have a huge matrix and I need to find this number and its row and coloumn than how can I find using find command etc. Thanks in advance.

 採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 11 月 21 日
編集済み: KALYAN ACHARJYA 2021 年 11 月 21 日

0 投票

Hints: Use logical indexing
  1. Get the data those are greater than 1: mat>1
  2. Subtract 1 from all elements of the matrix - mat-1
  3. Get the min one - min(mat)

その他の回答 (0 件)

カテゴリ

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

質問済み:

2021 年 11 月 21 日

コメント済み:

2021 年 11 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by