Finding corners of a matrix inside a matrix.

6 ビュー (過去 30 日間)
Swapnil Rane
Swapnil Rane 2018 年 2 月 26 日
コメント済み: Swapnil Rane 2018 年 2 月 26 日
I have a matrix of size 50*80 which contains non-zero values in the center of matrix. for example-- I would like to extract the position of the corner elements in that matrix i.e position of (0,0,5,7) elements. Can anyone help me with the code?
A=[0 0 0 0 0 0 0 0 ;
0 0 0 2 4 5 0 0;
0 0 4 0 5 2 1 0;
0 0 5 8 7 6 7 0;
0 0 0 0 0 0 0 0;
end

採用された回答

Birdman
Birdman 2018 年 2 月 26 日
[r,c]=find(A~=0);
upperLeft=A(min(r),min(c))
lowerLeft=A(max(r),min(c))
upperRight=A(min(r),max(c))
lowerRight=A(max(r),max(c))
  6 件のコメント
Stephen23
Stephen23 2018 年 2 月 26 日
編集済み: Stephen23 2018 年 2 月 26 日
upperLeft = [min(r),min(c)]
etc.
Swapnil Rane
Swapnil Rane 2018 年 2 月 26 日
@KL and @Stephen Cobeldick, both of the code works for me.
Thank you, I really appreciate it.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by