i want to get string array corresponding another num array
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
A = [ "a", "b", "c"]
B = [ 4, 5, 6]
if B change to [ 6, 4, 5 ]
i want to output A= ["c", "a", "b"]
0 commentaires
Réponse acceptée
Stephen23
le 28 Nov 2022
Aold = ["a","b","c"];
Bold = [4,5,6];
Bnew = [6,4,5];
[X,Y] = ismember(Bnew,Bold);
Anew = Aold(Y(X))
2 commentaires
Stephen23
le 28 Nov 2022
"but i want use same var name A , B not use Bnew Bold"
A = ["a","b","c"];
B = [4,5,6];
tmp = B;
B = [6,4,5];
[X,Y] = ismember(B,tmp);
A = A(Y(X))
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Characters and Strings dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!