Delete table row if var1 not equal to certain string
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
roblocks
il 24 Mag 2016
Modificato: Stephen23
il 24 Mag 2016
Dear All,
as mentioned above I am trying to delete a rows of a table if the variable (column) "NATION" is not equal to "UNITED STATES". A similar problem is discussed here, unfortuantely the code presented does not help me a lot. I tried to use:
definitions(cellfun(@isempty, strfind(definitions.NATION, 'UNITED STATES')),:)
which deletes all UNITED STATES entries, but thats the opposite of what I want. I need the same thing with NOT united States as critereon. It seems like there should be a solution to this. Can anyone help??
I would really appreciate it!!
0 Commenti
Risposta accettata
Azzi Abdelmalek
il 24 Mag 2016
%-------------------Example------------------------
s={ 'Algeria',1 2;'United States' 3 4;'France' 6 7}
A=cell2table(s)
%------------------------------------------------------
idx=ismember(A.s1,'United States')
A(~idx,:)=[]
2 Commenti
Stephen23
il 24 Mag 2016
Modificato: Stephen23
il 24 Mag 2016
@roblocks: the documentation "Contents" on the left-hand side of the page are a clickable hierarchy of pages: if you open the page that you found then you can click on "Tables" to go up one level: there you will find all topics discussing tables and how to use them. You will also see that there is a similar section explaining structures...
Two minutes spent learning how to use the Contents will be time well spent: you will learn how to find information all by yourself without having to ask random stranger on the internet, and you might just discover some thing new too!
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!