フィルターのクリア

Filtering the Content of an Array

160 ビュー (過去 30 日間)
RDG
RDG 2013 年 4 月 4 日
Suppose I have an array, arr with contents as follow:
A B C D
1 3 2 3
1 4 1 2
1 3 3 5
2 6 1 4
2 5 4 3
2 6 3 3
2 4 3 2
2 5 4 2
4 2 4 4
4 1 4 6
4 6 5 3
71 1 4 4
71 3 2 3
71 3 1 1
71 4 1 3
71 3 2 3
71 5 2 2
How can I filter the results to achieve the following:
A B C D
2 6 1 4
2 5 4 3
2 6 3 3
2 4 3 2
2 5 4 2
71 1 4 4
71 3 2 3
71 3 1 1
71 4 1 3
71 3 2 3
71 5 2 2
  1 件のコメント
Jan
Jan 2013 年 4 月 4 日
編集済み: Jan 2013 年 4 月 4 日
There is an infinite number of possible solutions. Although we can try to use our crystal balls, this could be a source of missunderstandings. Please explain the wanted procedure with any details.
Please note, that the type and size of the "arrays" is not clear: Does "A,B,C,D" belong to the array, such that it must be a cell arrays, because numerical arrays cannot contain numbers and characters? Or ist this any kind of header, and the actual data are 4 vectors or 1 matrix?
The less we have to guess, the easier and more likely helpful is the answer.

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

採用された回答

Andrei Bobrov
Andrei Bobrov 2013 年 4 月 4 日
編集済み: Andrei Bobrov 2013 年 4 月 4 日
ABCD = [1 3 2 3
1 4 1 2
1 3 3 5
2 6 1 4
2 5 4 3
2 6 3 3
2 4 3 2
2 5 4 2
4 2 4 4
4 1 4 6
4 6 5 3
71 1 4 4
71 3 2 3
71 3 1 1
71 4 1 3
71 3 2 3
71 5 2 2];
out = ABCD(ABCD(:,1) == 2 | ABCD(:,1) == 71,:);
or
out = ABCD(ismember(ABCD(:,1),[2 ,71]),:);

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by