Borrar filtros
Borrar filtros

Renaming Imported Variable with Initally Unknown Name

1 visualización (últimos 30 días)
Colin
Colin el 21 de Ag. de 2014
Respondida: Iain el 21 de Ag. de 2014
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!

Respuesta aceptada

Iain
Iain el 21 de Ag. de 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.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by