Accessing Workspace variables

3 ビュー (過去 30 日間)
Erik
Erik 2011 年 3 月 4 日
I currently have a list of arrays in my workspace that I loaded in from a .mat file. They are all really large 2 column arrays, that I need to combine and sort and place into a csv file. My goal is to automate the process so it can work for all different types of files.
The issue is that I do not know how to access variables in the workspace without typing in their names. So for instance lets say I have variable A in the workspace. I want to be able to access the data inside of A without directly using the variable name A in my code. That way I can loop through all the variables stored inside of the workspace and take out the data and put it into my new csv. I'm currently getting the variable names from who and trying to use eval() to actually get the data but I can't seem to get it working correctly.
I hope I made my question clear, thanks for your time.

採用された回答

Brett Shoelson
Brett Shoelson 2011 年 3 月 4 日
Sorry, Erik. I didn't read your question carefully enough.
Try this:
eval(b(ii).name)
Brett
  1 件のコメント
Erik
Erik 2011 年 3 月 4 日
Thanks, that did the trick.

サインインしてコメントする。

その他の回答 (1 件)

Brett Shoelson
Brett Shoelson 2011 年 3 月 4 日
A = whos;
for ii = 1:numel(A)
A(ii).name
end
Cheers, Brett
  1 件のコメント
Erik
Erik 2011 年 3 月 4 日
Well, I was already able to get the names of the variables. I'm trying to get the actual data each one stores. Unless of course there is something fairly obvious I am missing.

サインインしてコメントする。

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by