Changing data headers in a table (looped)
Mostrar comentarios más antiguos
I have a large data file gathering information from some test equipment in the field. Two pieces of equipment a generating more or less the same headers, ultimately i am trying to sync the two tables so I can plot time stamped data from both. As part of this, I want to rename some of the variables in the table, and usually they occur sequentially.
For example:
FullBR_1_ FullBR_2_ FullBR_3_ and so on up to 8. I would like to change the names to something else, but maintain the numbering. ie:
EFB_1 EFB_2 EFB_3
I have read a bunch of answer in here that point out why creating variables should not be done dynamically, however I think I am just trying to change the dynamic field names instead? My code is as follows:
close all
clear
e_table = readtable('CSM.dat');
s_table = readtable('CSS.dat');
for i=1:8
var_name = ['FullBR_' num2str(i) '_']
nvar_name = ['EFB_' num2str(i)]
e_table.Properites.VariableNames{var_name} = nvar_name;
end
I have a feeling this is due to my own ignorance on what the proper way to store the data is, so any advice would be apprecaited. I have skimmed this: https://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval#answer_236124
But it is kind of information overload.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!