Vertically Concatenating Tables in a Loop

13 visualizaciones (últimos 30 días)
Isabelle Museck
Isabelle Museck el 26 de Mzo. de 2024
Respondida: Chunru el 26 de Mzo. de 2024
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!

Respuesta aceptada

Chunru
Chunru el 26 de Mzo. de 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

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by