Find given element in column 1 with "find" function.

Hello all, I am trying to use "find" function and I want to find the given number in 1st column only. For example if I have a matrix A= [ 1 1 3;1 2 3;1 2 1]; and I want to find 1's in column 1 by using P=find(A==1). My ans is P= [1;2;3;4;9] which are the indexes of 1. I want only 1st column output which should be [1;2;3]. Please help if you have any idea. Thank you.

 採用された回答

bio lim
bio lim 2015 年 7 月 24 日
編集済み: bio lim 2015 年 7 月 24 日

0 投票

A = [ 1 1 3;1 2 3;1 2 1];
P = find(A(:,1)==1);

2 件のコメント

Navya Snigdha Thumma
Navya Snigdha Thumma 2015 年 7 月 24 日
編集済み: Navya Snigdha Thumma 2015 年 7 月 24 日
Thankyou very much. It worked.
bio lim
bio lim 2015 年 7 月 24 日
Glad to help. :)

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by