MATLAB Answers

How to compare two columns in a table and delete that row having same values in that columns?

2 views (last 30 days)
Sanwal Zeb
Sanwal Zeb on 12 Apr 2021
Commented: dpb on 18 Apr 2021
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

Answers (2)

dpb on 12 Apr 2021
c=string({'column1' 'column 2' 'columns3'
'ball' 'bat' 'gloves'
'bat' 'gloves' 'bat'
'ball' 'gloves' 'ball'});
>> 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...

Community Treasure Hunt

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

Start Hunting!

Translated by