How to compare two columns in a table and delete that row having same values in that columns?
1 次查看(过去 30 天)
显示 更早的评论
column1 column 2 columns3
ball bat gloves
bat gloves bat
ball gloves ball
Mow if I compare column1 and column3, I want to remove the rows having same values in that row of the columns
0 个评论
回答(2 个)
dpb
2021-4-12
c=string({'column1' 'column 2' 'columns3'
'ball' 'bat' 'gloves'
'bat' 'gloves' 'bat'
'ball' 'gloves' 'ball'});
c=c(c(:,1)~=c(:,3),:);
returns
>> c
c =
2×3 string array
"column1" "column 2" "columns3"
"ball" "bat" "gloves"
>>
I kept the header row to have something else in the array as a result...
0 个评论
Sanwal Zeb
2021-4-18
1 个评论
dpb
2021-4-18
Well, we'll have to see what you really have to write actual syntax...we can't see your workspace from here...
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 String Parsing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!