Assign values to string array

A = [x,y,z1]; B = [1,6,7];
and wherever x comes in program it should be replaced by its values 1, y by 6 and so on.....
thank you

1 comentario

Daniel Shub
Daniel Shub el 23 de Nov. de 2012
I am closing this question as a doit4me. Please say what you have tried.

Respuestas (2)

Matt J
Matt J el 23 de Nov. de 2012

0 votos

A=B
It seems like you run into many applications of this command, judging from your previous question here
Azzi Abdelmalek
Azzi Abdelmalek el 23 de Nov. de 2012

0 votos

A={'x','y','z'};
B=[1 6 7];
arrayfun(@(x) assignin('base',A{x},B(x)),1:length(A))

La pregunta está cerrada.

Etiquetas

Preguntada:

sp
el 23 de Nov. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by