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

1 回表示 (過去 30 日間)
Sanwal Zeb
Sanwal Zeb 2021 年 4 月 12 日
コメント済み: dpb 2021 年 4 月 18 日
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

回答 (2 件)

dpb
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...

Sanwal Zeb
Sanwal Zeb 2021 年 4 月 18 日
Hi, I want to do this in tables not in strings.
  1 件のコメント
dpb
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 ExchangeString Parsing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by