how i do loop over column?

1 visualización (últimos 30 días)
Lilya
Lilya el 15 de Dic. de 2017
Comentada: Lilya el 15 de Dic. de 2017
hi all,
I have a matrix with the dim of 978 * 744 which I want to loop over a number of a column with time step equal to 168 (hr/week) to have the final matrices of each week separately with the same number of rows 978
could anyone help me with, please?
thank you in advance.
  2 comentarios
KSSV
KSSV el 15 de Dic. de 2017
Read about reshape
Lilya
Lilya el 15 de Dic. de 2017
KSSV, thank you for your response. but I cant get the result

Iniciar sesión para comentar.

Respuesta aceptada

KL
KL el 15 de Dic. de 2017
Editada: KL el 15 de Dic. de 2017
If you want to do time-based calculation with your data, for example, weekly average or something I'd highly recommend using timetables (version 16b and above). Even for versions a bit older than that, use tables with datevec and then varfun.
Take a look at the examples on this page: https://www.mathworks.com/help/matlab/timetables.html
  5 comentarios
KL
KL el 15 de Dic. de 2017
Editada: KL el 15 de Dic. de 2017
@Guillaume: hmm, I kind of thought I might need datevec components to group but yeah, I agree, using proper datetime format is a better approach.
...I decided to 'trim' the data ...
@Lina: Don't do that. You don't have to lose any data. Simply import your data using readtable
data = readtable(filename);
convert it to timetable,
TT = table2timetable(data,'rowtimes',here goes your datetime column)
then use retime,
TT_weekly = retime(TT,'weekly','mean')
Lilya
Lilya el 15 de Dic. de 2017
Fantastic * _ * ... thanks so much!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by