Borrar filtros
Borrar filtros

Calculations for Each Table in a Cell

1 visualización (últimos 30 días)
Isabelle Museck
Isabelle Museck el 3 de Jun. de 2024
Comentada: Isabelle Museck el 3 de Jun. de 2024
Hello I have displacement and time data from 10 different trials stored as tables in a 10x1 cell. I am trying to calculate the velocity for each of the trials and store the data as a DOUBLE rather than a a table in a 10x1 cell.
Say CoPyData is the 10x1 cell with the 10 tables containing the time and displacement data. My code so far is:
CoPvAll = {}
for i =1:numel(CoPyData)
Trial = CoPyData{i,1}
CoPv_y = diff(Trial.Displacement)./diff(Trial.Time)
CoPv = [zeros(1);CoPv_y]
T = addvars(Trial,CoPv)
CoPvAll = {CoPvAll,T}
end
however this code is not correctly storing the data/calculated velocity back into a 10x1 cell and I am not sure how to convert the data from tables to doubles. Any help is greatly appreciated.

Respuesta aceptada

Matt J
Matt J el 3 de Jun. de 2024
Editada: Matt J el 3 de Jun. de 2024
for i =1:numel(CoPyData)
Trial = CoPyData{i};
CoPv_y = diff(Trial.Displacement)./diff(Trial.Time);
CoPv = [zeros(1);CoPv_y];
CoPyData{i} = addvars(Trial,CoPv);
end
  3 comentarios
Matt J
Matt J el 3 de Jun. de 2024
Assuming your table data is purely numeric, you can do as follows,
for i = 1:numel(CoPyData)
Trial = CoPyData{i};
CoPv_y = diff(Trial.Displacement)./diff(Trial.Time);
CoPv = [zeros(1);CoPv_y];
T = addvars(Trial,CoPv);
CoPyData{i}= double(T{:,:});
end
Isabelle Museck
Isabelle Museck el 3 de Jun. de 2024
Thank you so much!

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by