How to make this matrix
Show older comments
I want Matlab to create a 12x31 matrix that looks like the result of the following code.
M = [1:31; 32:59,0 0 0; 60:90; 91:120,0; 121:151; 152:181,0; 182:212; 213:243; 244:273,0; 274:304; 305:334,0; 335:365]
However, I want Matlab to calculate the element values and place the zeros accordingly, rather than me calculating the ranges and placing the zeros. Is this possible? Basically, I want a more simple code to produce this same result. Thanks
1 Comment
David Goodmanson
on 2 Feb 2018
what about leap year?
Accepted Answer
More Answers (0)
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!