Compare two Vectors and multiply equal entries
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Dom
am 13 Okt. 2021
Beantwortet: Stephen23
am 13 Okt. 2021
Hi,
I got an orignal dataset with a set of IDs and a unique characteristic value for each ID. For example ID A has the characteristic value 1, ID B has 2 ID C has 3 and so on. I got a second array with entries like AABBCDDDEFFE and I want to create a resulting array that looks like 112234445665, how would you do that?
Thanks!
0 Kommentare
Akzeptierte Antwort
Stephen23
am 13 Okt. 2021
ID = 'ABCDEF';
val = 1:6;
arr = 'AABBCDDDEFFE';
[X,Y] = ismember(arr,ID);
out = val(Y(X))
0 Kommentare
Weitere Antworten (0)
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!