Create single variable from workspace variables
古いコメントを表示
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 件のコメント
KSSV
2018 年 5 月 15 日
Read about whos
Juri Ymeraj
2018 年 5 月 15 日
@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?
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Variables についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!