Find function - index by rows?

For the find function, I noticed that it indexes downward column by column. Is there a way to make it so that it indexes left to right row by row?

1 件のコメント

Stephen23
Stephen23 2016 年 4 月 27 日
Nope. Transpose your data and start thinking in terms of columns, not rows.

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

回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 4 月 27 日

0 投票

Apply find function to the transpose of your matrix
find(A'==2) % for example

2 件のコメント

Eric Tran
Eric Tran 2016 年 4 月 27 日
Is there a way to do it without changing the orientation of the matrix. I'm trying to find the indices for "marching band member positions" and I want to try "moving" members one at a time down a row. With how the find function works now, the members are moving one at a time down a column and I'm running into some issues with that method, so I want to see how doing so with rows would affect my desired output.
Azzi Abdelmalek
Azzi Abdelmalek 2016 年 4 月 27 日
You are not changing your Matrix, your are just operating on another Matrix which is A'

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

Andrei Bobrov
Andrei Bobrov 2016 年 4 月 27 日
編集済み: Andrei Bobrov 2016 年 4 月 27 日

0 投票

Example:
A = rand(15) > .4; % your array
[i0,j0] = find(A);
c = num2cell(sortrows([i0,j0],1),1);
[i_out,j_out] = c{:};
or jast (as by Azzi)
[j_out,i_out] = find(A.');

カテゴリ

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

製品

質問済み:

2016 年 4 月 27 日

コメント済み:

2016 年 4 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by