how do I call an array by having a matrix which juxtaposes a standard name with a tag?

3 ビュー (過去 30 日間)
I have many tables like so : TABLE_DD
TABLE_NN
TABLE_PP
...
and so on with various tags.
Is there any way to refer to the table by doing this :
>>A = ['TABLE_' Tags{1}];
where Tags = {'DD','NN','PP' ...};?
It would make life so much easier.

採用された回答

the cyclist
the cyclist 2013 年 7 月 6 日
First, I would say you might want to take a look at this thread, which talks about using numbered cell arrays instead of sequences of variable names. It might point you to a better solution.
That being said, it is possible to do what you want:
TABLE_NN = rand(3);
TABLE_PP = rand(3);
tags = {'NN','PP'};
eval(['A = TABLE_',tags{1}])

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by