フィルターのクリア

deleting rows with a criteria for repeating indices

2 ビュー (過去 30 日間)
masih
masih 2017 年 6 月 29 日
コメント済み: masih 2017 年 6 月 29 日
Hi All,
I have this matrix:
460231 1
406962 1
407721 1
407963 1
409590 1
480657 2
527635 2
525820 2
624575 2
593871 2
548098 3
542776 3
544329 3
553168 3
552825 3
473360 1
410370 1
408704 1
407852 1
409568 1
462219 2
510423 2
508923 2
508207 2
507325 2
and I want to do the following to the matrix. Can you please help me how to do it?
1- I want to remove all rows whose second column is 2.
2-For the remainder of the matrix, I want to delete the first two rows whose second column is 1 and 3
So, the output I want should look like this:
407721 1
407963 1
409590 1
544329 3
553168 3
552825 3
408704 1
407852 1
409568 1

採用された回答

Stephen23
Stephen23 2017 年 6 月 29 日
>> B = A(A(:,2)~=2,:);
>> X = diff(B(:,2))~=0;
>> X = [true;X] | [true;true;X(1:end-1)];
>> C = B(~X,:)
C =
407721 1
407963 1
409590 1
544329 3
553168 3
552825 3
408704 1
407852 1
409568 1

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by