how find idx string deleted

1 view (last 30 days)
piero
piero on 29 Nov 2023
Answered: Fangjun Jiang on 29 Nov 2023
a={'aa','bb','cc','aa'}
a = 1×4 cell array
{'aa'} {'bb'} {'cc'} {'aa'}
unique(a,'stable')
ans = 1×3 cell array
{'aa'} {'bb'} {'cc'}
%i want to find idx string deleted..( idx=4)

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 29 Nov 2023
a={'aa','bb','cc','aa'};
[b,ida,idb]=unique(a,'stable')
b = 1×3 cell array
{'aa'} {'bb'} {'cc'}
ida = 3×1
1 2 3
idb = 4×1
1 2 3 1
setdiff(1:numel(a),ida)
ans = 4

More Answers (0)

Categories

Find more on Characters and Strings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!