Borrar filtros
Borrar filtros

Delete table row if var1 not equal to certain string

6 visualizaciones (últimos 30 días)
roblocks
roblocks el 24 de Mayo de 2016
Editada: Stephen23 el 24 de Mayo de 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!!

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 24 de Mayo de 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 comentarios
roblocks
roblocks el 24 de Mayo de 2016
Dear Azzi Abdelmalek,
thanks for your help, problem solved. Are you aware of a good compendium which discusses how to solve problems like the one above? I only know of this, and it is way to short. Basically like a list of useful commands if one wants to organize, format and display desciprtive statstics of data in tables (and structures for taht matter).
Any idea? :)
Best, and thanks again!
Stephen23
Stephen23 el 24 de Mayo de 2016
Editada: Stephen23 el 24 de Mayo de 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!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Tables en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by