Create single variable from workspace variables
Mostrar comentarios más antiguos
I have many variables in the form (:,1) with different names in my workspace. What i want to achieve is to write a script that generates me a single variable in a table form with the values of any variable in columns with the name of the variable on top of the column. Somehow this script should go to the first variable in the workspace and store the content and the name in the generated variable in (:,1), the second in (:,2) and so on.
What i am missing is exactly the idea/way how to achieve that the script gets the variables one by one in the order in which they are in the workspace. Has anyone of you an idea?
3 comentarios
KSSV
el 15 de Mayo de 2018
Read about whos
Juri Ymeraj
el 15 de Mayo de 2018
@Juri Ymeraj: the best solution is to avoid this situation entirely. Luckily this is usually trivially easy to avoid, e.g. by load-ing into an output variable instead of simply spamming variables into the workspace:
S = load(...);
Note that dynamically accessing variable names is one way that beginners force themselves into writing slow, buggy, complex code that is hard to debug. You can read more about why here:
Thus the most important question is: how did you get all of those variables into the workspace?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Variables en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!