"For loop" to perform statistical analysis /math on separate sets of columns of table
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Sobhana Sripada
am 29 Dez. 2020
Kommentiert: Sobhana Sripada
am 29 Dez. 2020
I am trying to perform some data mining, cleaning and analysis on a set of data. I have imported my numerous excel files in the following format
(so their nomenclature can easily be used especially in for loops), to make a table "T_Joined".
FT{11} = readtable('TestM1FT1', 'Sheet', 1);
FT{12} = readtable('TestM1FT1', 'Sheet', 2); ..
I am now trying to create new columns in the table using values from existing columns of the table with column names "T_Joined.PSM1FT2", "T_Joined.PSM2FT3" etc. upon performing some math. I wrote the following 'for' loop because I will need to repeat this about 10 times.
for a=[2,3,4]
T_Joined.AvgFT{a} = (T_Joined.PSM1FT{a} + T_Joined.PSM2FT{a})./2;
end
However, the compiler returns:
"Error using tabular/numArgumentsFromSubscript (line 78)
Unrecognized table variable name 'PSM1FT'.
Error in XXX (line 71)
T_Joined.AvgFT{a} = (T_Joined.PSM1FT{b} + T_Joined.PSM2FT{b})./2;"
Looks like the right hand side of the way I used the variable a in the for loop - doesnt execute. I was wondering if I could get some assistance on rectifying this!
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 29 Dez. 2020
for a=[2,3,4]
T_Joined.("AvgFT"+a) = (T_Joined.("PSM1FT"+a) + T_Joined.("PSM2FT" +a) )./2;
end
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Tables finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!