Vertically Concatenating Tables in a Loop
13 次查看(过去 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!
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!