Borrar filtros
Borrar filtros

Store a double value into the cell array element

6 visualizaciones (últimos 30 días)
Fuad Numan
Fuad Numan el 6 de Abr. de 2012
I have a cell array, e.g
name={'A','B','C'};
I would like to extract the name elements and use them as variables, we know that,
name{1}=A
I want to assign 'A' a double value or vector;
name{1}=[1 2 3]; % this one is definitely wrong, it is just for example
then when i call A from the command-window, it should show [1 2 3]; is it possible to do that?
appreciate ur help

Respuesta aceptada

Geoff
Geoff el 6 de Abr. de 2012
You'd need to use eval, but there's almost always a good reason not to do what you're trying to do.
  1 comentario
Fuad Numan
Fuad Numan el 6 de Abr. de 2012
Thanx Geoff
the eval function used after the variable declaration;
I mean the variable has not assigned any values yet,
what I want to do is to use the cell array in a for loop, e.g.
name={'A' 'B' 'C'};
for i=1:3
name{i}=50*i^2;
end
I tried your suggestion,
eval(name{1})=50;
but it seems the A variable should assign a value before the declaration of cell array name.
the loop i gonna use is to long, i want to make it shorter and faster and store the variables in mat file.
Thanks again

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Tables en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by