Renaming Imported Variable with Initally Unknown Name

1 view (last 30 days)
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!

Accepted Answer

Iain
Iain on 21 Aug 2014
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.

More Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!