Store a double value into the cell array element

6 次查看(过去 30 天)
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

采纳的回答

Geoff
Geoff 2012-4-6
You'd need to use eval, but there's almost always a good reason not to do what you're trying to do.
  1 个评论
Fuad Numan
Fuad Numan 2012-4-6
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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Tables 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by