Filter löschen
Filter löschen

Delete table row if var1 not equal to certain string

6 Ansichten (letzte 30 Tage)
roblocks
roblocks am 24 Mai 2016
Bearbeitet: Stephen23 am 24 Mai 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!!

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 24 Mai 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 Kommentare
roblocks
roblocks am 24 Mai 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 am 24 Mai 2016
Bearbeitet: Stephen23 am 24 Mai 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!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Tables finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by