i want to get string array corresponding another num array

 Respuesta aceptada

Aold = ["a","b","c"];
Bold = [4,5,6];
Bnew = [6,4,5];
[X,Y] = ismember(Bnew,Bold);
Anew = Aold(Y(X))
Anew = 1×3 string array
"c" "a" "b"

2 comentarios

thank you
but i want use same var name A , B not use Bnew Bold
how to?
"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))
A = 1×3 string array
"c" "a" "b"

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Etiquetas

Preguntada:

el 28 de Nov. de 2022

Comentada:

el 28 de Nov. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by