How do I create a matrix with repeating values?

5 ビュー (過去 30 日間)
Andrew
Andrew 2012 年 2 月 29 日
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 Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by