フィルターのクリア

Store a double value into the cell array element

6 ビュー (過去 30 日間)
Fuad Numan
Fuad Numan 2012 年 4 月 6 日
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 Center および File ExchangeTables についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by