Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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.

Respuesta aceptada

the cyclist
the cyclist el 6 de Jul. de 2013
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}])

Más respuestas (0)

Categorías

Más información sobre Debugging and Analysis 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