problem while using 'intersect' between strings

11 views (last 30 days)
Yu Li
Yu Li on 8 Oct 2019
Commented: Star Strider on 8 Oct 2019
I have two strings:
[C,ia,ib] = intersect(s1,s2, 'stable');
the result is:
however, I think the expected result should be:
so I would like to know if there is any mistake with my understanding?

Accepted Answer

Star Strider
Star Strider on 8 Oct 2019
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.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!