フィルターのクリア

Renaming Imported Variable with Initally Unknown Name

1 回表示 (過去 30 日間)
Colin
Colin 2014 年 8 月 21 日
回答済み: Iain 2014 年 8 月 21 日
Hello All,
I am currently working on an automated data post-processing script which imports raw data (.dat file) and does some dynamic analysis. The issue I am currently having is that the variables that are imported are automatically appended with a certain number (ex. we have a vector for velocity... it becomes velocity_3 or velocity_4, etc...). The letters in the variable stay the same and are known, but the appended number depends on how the test to collect the data was conducted, so this is unknown beforehand.
I would like to rename all of the variables (ex. speed = velocity_3) so that I can analyze the variables (ex. speed) later on in my code. Right now I have some code which determines the name of each variable (ex. speed_3) and stores it to a "char" variable, however I cannot figure out how to call out the variable since it is stored as a char value.
Any recommendations on how to proceed from here, or an easier solution would be greatly appreciated!
Thanks!

採用された回答

Iain
Iain 2014 年 8 月 21 日
eval or setfield can do something for you I think
You would do better to change your code that reads the files to not name the variables in such a silly way though.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by