Vertically Concatenating Tables in a Loop
13 views (last 30 days)
Show older comments
Hi there I am trying to perform a calculation on variables in each trial of a data set and add it to the table and concationte the tables with caluclated variables over the course of 10 trials. So far I have this code
for m = 1:10
Trial = [COPData(m).data,OPALData(m).data]; %Original Table
COPTv_y = diff(Trial.COPy)./diff(Trial.Time); %Center of pressure calcualtion velocity in y-direction
Table = addvars(Trial,COPTv_y,'NewVariableNames',{'CoP_velocity'}); %adds new CoPv clalcuation to table
end
but it just produces 10 seperate tables in the workspace all named "Table" and I was to stack the tables on top of eachother so it contains all the data including the new calucalted variable across the 10 tirals. Any help is greatly appreciated! Thank you so much!
0 Comments
Accepted Answer
Chunru
on 26 Mar 2024
TableAll = [];
for m = 1:10
Trial = [COPData(m).data,OPALData(m).data]; %Original Table
COPTv_y = diff(Trial.COPy)./diff(Trial.Time); %Center of pressure calcualtion velocity in y-direction
T = addvars(Trial,COPTv_y,'NewVariableNames',{'CoP_velocity'}); %adds new CoPv clalcuation to table
TableAll = [TableAll; T]; % append T to TableAll
end
0 Comments
More Answers (0)
See Also
Categories
Find more on Logical 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!