form a matrix with the day type codification

12 次查看(过去 30 天)
Hello,
Please help me with the following:
Consider a 365x2 matrix, called A, that contains a day type codification for 2009 (in the 1st column):
Mondays=1, Tuesdays=2,..., Sundays=7.
The 1st week of 2009 is 4,5,6,7,1,2,3 because the 1st day was Thursday, so the 1st 7 rows have the aforementioned values.
The 2nd column of A has some random values that correspond to each day of the year.
Also consider a 365x2 matrix, called B, with the same elements for 2010.
The 1st week of 2010 is 5,6,7,1,2,3,4, because the 1st day was Friday (1 day type shift ahead from 2009).
Again, the 2nd column of B has some random values
How can I form a 365x2 matrix, called C, that takes the day type mean values of A and B and refers to 2011.
The 1st week of 2011 is 6,7,1,2,3,4,5. The rows of C should be like this:
The 1st day of 2011 is Saturday so the 1st row of C should have the mean values of the 2nd columns of 2009 and 2010 of the corresponding 1st Saturdays (in A the 1st Saturday is the 3rd row and in B is the 2nd row).
The 2nd day of 2011 is Sunday so we will take the 4th row of A and the 3rd of B and so on.
Thank you very much.
Best,
Pavlos

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by