Store a double value into the cell array element

7 views (last 30 days)
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

Accepted Answer

Geoff
Geoff on 6 Apr 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 Comment
Fuad Numan
Fuad Numan on 6 Apr 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

Sign in to comment.

More Answers (0)

Categories

Find more on Tables in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!