Vertically Concatenating Tables in a Loop

8 次查看(过去 30 天)
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!

采纳的回答

Chunru
Chunru 2024-3-26
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 个)

类别

Help CenterFile Exchange 中查找有关 Tables 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by