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!