Subtractions between consecutive rows in a table
Mostrar comentarios más antiguos
I need a help to obtain the differences between time values which I read alongside other data and write them to a CSV file as a table. The time values are those of MATLAB time converted into milliseconds, but what I need is the differences between them to be in the table as the time is read. That is row 3 - row2, row4 - row3, row5 - row4,.......rowend - row(end-1). I attached a CSV file where I read 30 samples. Here is the relevant segment of my code:
counter = 0;
logtime_table = table();
while(counter< 30)
Timestamp = now;
timestring = datestr(Timestamp,'HH:MM:SS.FFF');
[~,~,~,hours,minutes,seconds] = datevec(timestring);
Timestamp = 1000*(3600*hours + 60*minutes + seconds);
table_row = table(Timestamp);
logtime_table = [logtime_table; table_row];
counter = counter + 1;
end
filename = strcat('logtime_table.csv');
writetable(logtime_table, filename);
Respuesta aceptada
Más respuestas (1)
KSSV
el 24 de Sept. de 2018
0 votos
Read about function diff. It will give you the required difference.
2 comentarios
DEYIRE UMAR
el 27 de Sept. de 2018
KSSV
el 27 de Sept. de 2018
It will.....you need to enter doubles into it.
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!