How can I find which row has a specied values that I entered?

1 回表示 (過去 30 日間)
metehan akinci
metehan akinci 2019 年 2 月 6 日
コメント済み: Luna 2019 年 2 月 12 日
So for example;
Lets say
A=[4 5 6 7; 8 4 5 6;4 5 6 8;8 4 8 9 ;1 2 2 4;5 3 4 6];
and i want to find which row has the vector of [4 5 6 8];
Thanks
M.A

採用された回答

Luna
Luna 2019 年 2 月 6 日
For example,
A=[4 5 6 7; 8 4 5 6; 4 5 6 8; 8 4 8 9 ;1 2 2 4; 4 5 6 8]; % A matrix
v = [4 5 6 8]; % vector you are searching for
[flag,locs] = ismember(A,v,'rows'); % flag gives logical true for each row if v is equal to corresponding row of A
locations = find(flag); % if you want to get exact location such as 3rd row, 5th row and if you are using with rows option, use this.
  2 件のコメント
metehan akinci
metehan akinci 2019 年 2 月 12 日
Thank you for your answer!
Luna
Luna 2019 年 2 月 12 日
Your welcome :)

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

その他の回答 (1 件)

John D'Errico
John D'Errico 2019 年 2 月 6 日
help ismember
Read about the 'rows' option.

カテゴリ

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

製品


リリース

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by