How do convert array x to array z?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hamidreza Rafat
am 28 Aug. 2018
Bearbeitet: Andrei Bobrov
am 28 Aug. 2018
Hi, How do convert array x to array z ?
x = [4 4 8 8 8 5 5 4 8 8 4]
Z = [1 1 2 2 2 3 3 1 2 2 1]
4 -> 1
8 -> 2
5 -> 3
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Andrei Bobrov
am 28 Aug. 2018
Bearbeitet: Andrei Bobrov
am 28 Aug. 2018
or just:
[~,~,z] = unique(x,'stable');
or more
[~,z] = ismember(x,[4 8 5]);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!