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

KSSV
KSSV 2017년 12월 15일
Read about reshape
Lilya
Lilya 2017년 12월 15일
KSSV, thank you for your response. but I cant get the result

댓글을 달려면 로그인하십시오.

 채택된 답변

KL
KL 2017년 12월 15일
편집: KL 2017년 12월 15일

0 개 추천

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

Lilya
Lilya 2017년 12월 15일
KL, thank you for your answer. Yes, I did. the point is: this function calculating the weekly mean that I don't need it I just need the all values in each weed and each has a separet matrix.
Guillaume
Guillaume 2017년 12월 15일
@KL, I would use datetime which is a lot more powerful than datevec.
@Lina, with timetables you can calculate, weekly, monthly, hourtly, quaterly, etc. anything, not just mean. One thing for sure, you do not want to split weeks in separate matrices. Whatever it is you're trying to do, it will be harder once you've split your original data into several matrices.
If you give more details about what you're doing, we can show you how to do it simply.
Lilya
Lilya 2017년 12월 15일
thanks for the clarification Guillaume :).
ok. as you know the number of weeks in each month are different regarding the number of days. so I decided to 'trim' the data like just to have 4 weeks in each month therefore the original matrix (978*744 for example) should give 4 weeks each has (978*168) with neglecting the remain couple days.
I hope this clear now
KL
KL 2017년 12월 15일
편집: KL 2017년 12월 15일
@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 2017년 12월 15일
Fantastic * _ * ... thanks so much!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

태그

질문:

2017년 12월 15일

댓글:

2017년 12월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by