Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Delete some rows where column 1 = certain value

2 ビュー (過去 30 日間)
sm m
sm m 2016 年 10 月 18 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
How can I delete only the rows where the column1 value = 1 or 101 or 102
My matrix is 10000 *137. i WANT TO DELETE ALL THE ROWS WHERE MY COLUMN 1 ENTRY IS EITHER OF THESE VALUES. Unique values in my column1 are 1, 101, 102, 105, 34,45,67,22,32
The other option I have is : I want to retain only those rows where my columns are 67, 22, 32 Are there specific commands tht I can use for these two situations?

回答 (2 件)

KSSV
KSSV 2016 年 10 月 18 日
data = rand(100,2) ; % random data
% add 1,101,102 randomly
data(randsample(1:100,10),1) = 1 ;
data(randsample(1:100,7),1) = 101 ;
data(randsample(1:100,15),1) = 102 ;
%%remove rows with 1 , 101 and 102
data(data(:,1)==1,:) = [] ;
data(data(:,1)==101,:) = [] ;
data(data(:,1)==102,:) = [] ;
  1 件のコメント
Walter Roberson
Walter Roberson 2016 年 10 月 18 日
You do not need three deletions.
data(ismember(data(:,1), [1, 101, 102]), :) = [];

Andrei Bobrov
Andrei Bobrov 2016 年 10 月 18 日
out = your_data(ismember(your_data(:,1),[67, 22, 32]),:);

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by