Hello,
So, my problem is : I have a matrix let's call it A :
0 1 0 0
A = 0 0 1 0
0 0 0 0
1 0 1 0
I want to find the rows and cols of all the "1" in A, I used find and got :
[rows cols] = find (A == 1)
rows = 4 1 2 4 and cols = 1 2 3 3
now that's not what I want, as the search in A goes "top to bottom, left to right" and I want it to be "left to right, top to bottom", so the result should be something like this :
rows = 1 2 4 4 and cols = 2 3 1 3
Any ideas ?
Thanks.

 採用された回答

Andrei Bobrov
Andrei Bobrov 2017 年 4 月 11 日

0 投票

[cols rows] = find (A.' == 1)

その他の回答 (2 件)

Adam
Adam 2017 年 4 月 11 日
編集済み: Adam 2017 年 4 月 11 日

2 投票

[cols, rows] = find( A' == 1 )
Abdel A
Abdel A 2017 年 4 月 13 日

0 投票

You my friend is a genius. I did think of the matrix transpose but didn't think of reversing cols and rows. Thanks.

カテゴリ

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

タグ

質問済み:

2017 年 4 月 11 日

回答済み:

2017 年 4 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by