remove rows if they contain ?

1 Ansicht (letzte 30 Tage)
Catherine Branter
Catherine Branter am 23 Feb. 2019
Bearbeitet: Image Analyst am 23 Feb. 2019
I want to remove all rows that contain ?
The issue is that ? could be in any of my 14 columns
I tried this code ("data" is the name of my table here)
data(ismember(data,'?'),:)=[];
but i get the error
Error using tabular/ismember (line 37)
A and B must both be tables, or both be timetables.
  1 Kommentar
madhan ravi
madhan ravi am 23 Feb. 2019
upload your table as .mat file

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 23 Feb. 2019
Bearbeitet: Image Analyst am 23 Feb. 2019
This works:
column1 = {'a'; 'b'; '?'; 'c'; 'd'}
column2 = {'a'; '?'; 'x'; 'c'; 'd'}
data = table(column1, column2)
% Now that we have sample data, delete any column with a '?' in it.
rowsToDelete = any(contains(data{:, :} , '?'), 2)
data(rowsToDelete, :) = []

Kategorien

Mehr zu Tables 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!

Translated by