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 Center および File ExchangeNumeric Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by