How can I delete rows in which a specific value is present?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Vishnu Roy
am 28 Okt. 2021
Beantwortet: Star Strider
am 28 Okt. 2021
I have a dataset of 12 columns and 70,000 rows. I want to delete the rows in which any of the columns has a value 999.25 as it represents null in my data set. What would be the simplest way of doing this as a beginner?
0 Kommentare
Akzeptierte Antwort
Yongjian Feng
am 28 Okt. 2021
How about this?
dataset = ones(100, 12); % use your own data instead here
sz = size(dataset);
rowCount = sz(1);
for i=1:rowCount
if any(dataset(i, :) == 999.25)
dataset(i, :) = []; % delete row
end
end
0 Kommentare
Weitere Antworten (1)
Star Strider
am 28 Okt. 2021
Try something like this —
D = randi(9, 10, 12);
D(randi(numel(D),1,3)) = 999.25
D = D(~any(D==999.25,2),:)
This searches for any ‘999.25’ value by row, and then keeps only the rows without that particular value.
.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Database Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!