Delete table row if var1 not equal to certain string
3 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Azzi Abdelmalek
2016 年 5 月 24 日
%-------------------Example------------------------
s={ 'Algeria',1 2;'United States' 3 4;'France' 6 7}
A=cell2table(s)
%------------------------------------------------------
idx=ismember(A.s1,'United States')
A(~idx,:)=[]
2 件のコメント
Stephen23
2016 年 5 月 24 日
編集済み: Stephen23
2016 年 5 月 24 日
@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!
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!