Hi everyone,
i need to create a cell array containing time values from 00.00 to 23.59 with a step of 1 minute.
00.00
00.01
00.02
..
00.59
01.00
01.01
..
..
23.59
Just to explain it better,
t_iniz_proc=datetime(2018,2,5,0,0,0);
t_end_proc=datetime(2018,2,5,23,59,0);
DataArray=(t_iniz_proc:minutes(1):t_end_proc)'
i need something like that but i don't want to include the data, just the time in format 'hh.mm'
Can anyone help me?
Thanks a lot!
Fabio

댓글 수: 4

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 3월 15일
With a step of 1 minute....means?
Fabio Pulcini
Fabio Pulcini 2019년 3월 15일
each time in the array should be 1 minute later than the previous one.
KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 3월 15일
That menas 0.00 >>i min Gap>>0.01>>1 Min wait.....upto 23.59
Is this you are asking, if yes then it takes much longer time to exucates..near about 2500 min??
Confirm?
Fabio Pulcini
Fabio Pulcini 2019년 3월 15일
no i don't need to pause the code.
I must create an array containing a time sequence that starts at midnight (00.00) of a not specified day and ends at 23.59 of that day. So that i can see each time minute by minute.

댓글을 달려면 로그인하십시오.

 채택된 답변

madhan ravi
madhan ravi 2019년 3월 15일

0 개 추천

DataArray.Format='H:mm'

댓글 수: 1

Fabio Pulcini
Fabio Pulcini 2019년 3월 15일
thank you so much! i was using the wrong syntaxis

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

KSSV
KSSV 2019년 3월 15일

0 개 추천

t = 00.00:0.01: 23.59 ;

댓글 수: 5

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 3월 15일
편집: KALYAN ACHARJYA 2019년 3월 15일
@Time sir?
I dont undestand the logic of the question, Is he asking this one?
for i=2:iter %iter value so that last cell element reached 23.59
a{i}=a{i-1}+0.01;
pause(n); % Pause sec n
end
a=a';
Fabio Pulcini
Fabio Pulcini 2019년 3월 15일
Thanks for the answer, but it generates an array containing values with 2 decimals till .99.
I need a time array, minute by minute from midnight to 23.59 h.
t0= hours(00.00) ;
t1 = hours(23.59) ;
t = t0:hours(0.01):t1
madhan ravi
madhan ravi 2019년 3월 15일
편집: madhan ravi 2019년 3월 15일
it's a duration array not a time array
KSSV
KSSV 2019년 3월 15일
So what? I gave two options..let the user decide what he wants....nothing is going to harm with that.

댓글을 달려면 로그인하십시오.

Steven Lord
Steven Lord 2019년 3월 15일

0 개 추천

minutesAfterMidnight = minutes(0):minutes(1):(hours(24)-minutes(1));
minutesAfterMidnight.Format = 'hh:mm';
firstTen = minutesAfterMidnight(1:10)
lastTen = minutesAfterMidnight(end-9:end)
You can add this to a datetime when or if you need times during a day.
minutesOfToday = datetime('today')+minutesAfterMidnight;
twoThirtyNineAM = minutesOfToday(2*60+40)
I added 40 instead of 39 when extracting 2:39 AM from minutesOfToday because 00:00 is element 1 of minutesAfterMidnight. Don't get caught by an off by one error.

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2019년 3월 15일

답변:

2019년 3월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by