Accessing data in doubles with incremental names using a loop

I have a list of data (doubles containing temperature and time stamp readings) with files names in an incresing order and I need to access temperature measurements from them.
Ex: I have the following doubles: Meas_Temp_1, Meas_Temp_2 and so on until Meas_Temp_60
I need a loop which will get me all the temperature readings in different variables, say
Temp n = Meas_Temp_n (:,1) -----> store the temperature data in the first column into variables
I am unable to extract the readings while I am able to access the doubles.

3 comentarios

Just to clarify, you have MATLAB workspace variable which are classed as doubles that have progressive names? If so, where do these variables come from?
It is generally considered bad practice to create a series of variables like this, and our first recommendation will be to change the creation method for these variables to create a multidimensional matrix.
Yes, the MATLAB workspace has variables which are classed as doubles and have progressive names. Each of these variable (doubles) are the measurement readings obtained from a BMS (battery management system). Each of these variables (doubles) contain temperature and time stamps> Each variable is a 7000*2 double and I have 64 such variables with progressive names from where I need to get only the temperature measurements (column 2 of the double) and store them into another variable say from T1 until T64. I need some kind of looping to get this.
Unfortunately, the creation of these variables in any other format is not possible given that it is from BMS.
Stephen23
Stephen23 el 14 de Mzo. de 2019
Editada: Stephen23 el 14 de Mzo. de 2019
"I have the following doubles: Meas_Temp_1, Meas_Temp_2 and so on until Meas_Temp_60"
Then you really really need to fix your data design. Numbered variables are a sign that you are doing something wrong.
"the creation of these variables in any other format is not possible given that it is from BMS. "
Saying that the data is "from BMS" tells us nothing about its format (e.g. is the data stored in files (what file format?) or as variables magically created in the workspace by a very badly written tool?).
In any case you should fix your code where the data is imported or created. For example, rather than load-ing into separate variables, simply load into one output variable (which is a structure):
S = load(...);
"I am unable to extract the readings while I am able to access the doubles."
Dynamically accessing variable names is one way that beginners force themselves into writing slow, complex, obfuscated, buggy code that is hard to debug. Read this to know some of the reasons why:

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 14 de Mzo. de 2019

Editada:

el 14 de Mzo. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by