problem while using 'intersect' between strings

조회 수: 11 (최근 30일)
Yu Li
Yu Li 2019년 10월 8일
댓글: Star Strider 2019년 10월 8일
Hi:
I have two strings:
s1='bound10-wall1.out'
s2='bound10-wall24.out'
[C,ia,ib] = intersect(s1,s2, 'stable');
the result is:
C='bound10-wal.t'
however, I think the expected result should be:
'bound10-wall.out'
so I would like to know if there is any mistake with my understanding?
Thanks!
Yu

채택된 답변

Star Strider
Star Strider 2019년 10월 8일
The letter ‘l’ appears twice in both strings, so is only returned once in the intersect result.
Yopu will get a similar result with:
s1u = unique(s1, 'stable')
s2u = unique(s2, 'stable')
and for the same reason.
  댓글 수: 2
Yu Li
Yu Li 2019년 10월 8일
thank you.
Star Strider
Star Strider 2019년 10월 8일
As always, my pleasure.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numeric Types에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by