How do I create a matrix with repeating values?

1 次查看(过去 30 天)
I'm trying to create a matrix with time values over 15 days increasing by 15 minute intervals. So it needs to be a 3x1536 matrix with a row for days, hours, and minutes.
the days row needs to have the value '0' for 96 times before it increase to 1, then 96 times again before it increases to 2 and so on..
the hours row needs to have the value 0 for 4 times before it increases to 2, then when after hour '23', it needs to start at 0 again..
and finally the minutes just need to [0 15 30 45], but repeating to the end. How do I do this??

回答(1 个)

Walter Roberson
Walter Roberson 2012-2-29
dn = linspace(0, 16, 1536+1); %include midnight after
dn(end) = []; %remove midnight after
dv = datevec(dn);
Now extract appropriate columns of dv, probably columns 3, 4, and 5

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by