Problem 2336. Calendar Matrix
Return a calendar matrix for the given values of month and year. Assume that Sunday is the first day of the week. The resulting calendar month will have seven columns and only as many rows (weeks) as needed to display all days of the month. Thus it might have either 4, 5, or 6 rows. Days preceding the first of the month or following the last of the month are given by zeros.
Examples
>> mo = 1 >> yr = 2014 >> momat = makeCalendar(mo,yr)
0 0 0 1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31 0>> mo = 2 >> yr = 2015 >> momat = makeCalendar(mo,yr)
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28>> mo = 10 >> yr = 2010 >> momat = makeCalendar(mo,yr)
0 0 0 0 0 1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31 0 0 0 0 0 0
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers148
Suggested Problems
-
Project Euler: Problem 6, Natural numbers, squares and sums.
2376 Solvers
-
Number of 1s in a binary string
10379 Solvers
-
494 Solvers
-
Are all the three given point in the same line?
590 Solvers
-
Return fibonacci sequence do not use loop and condition
711 Solvers
More from this Author50
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!