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 CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by