loop for clock in MATLAB
古いコメントを表示
hi all, I wanna do loop for an output to be like this
12:00
12:15
12:30
12:45
13:00
13:15
13:30
13:45
14:00
how can I get this output in MATLAB??? please help and advice...
2 件のコメント
Please add any details by editing the question, because it is not clear, what you want to achieve and which level of variability you want.
In addition it is recommended to use meaningful tags, because they are used to classify the questions. Nearly all questions concern "Matlab code". I'm not able to give better tags by my own, because you did not specify, if your problem concerns a TIMER, SPRINTF, FPRINTF to the command window or to a file, a GUI, etc.
Samer Husam
2012 年 7 月 5 日
採用された回答
その他の回答 (4 件)
Clock=char('12:00','12:15','12:30','12:45','13:00','13:15','13:30','13:45','14:00');
for i = 1:size(Clock,1)
Clock(i,:)
end
Does this help you
4 件のコメント
Samer Husam
2012 年 7 月 5 日
Luffy
2012 年 7 月 5 日
what does interval of 15 mins mean,i think it is already as interval of 15mins(12:00,12:15)
whatever interval u want say i,
try this:
datestr(datenum(0,0,0,12,(0:i:i*9)',0),'HH:MM');
if u want more values change 9 to number of values u need.
Samer Husam
2012 年 7 月 5 日
Kye Taylor
2012 年 7 月 5 日
Try running this script... It has some ideas you might use, but it is hardly optimal.
startTimeString = '12:00';
stopTimeString = '14:00';
startTimeDV = datevec(startTimeString);
stopTimeDV = datevec(stopTimeString);
timeInterval = input('Enter the time step in minutes.\n');
thisTime = startTimeDV;
while thisTime(4) < stopTimeDV(4)
% a hack to count +60 minutes as hour
thisTime = datevec(datestr(thisTime));
thisTimeString = datestr(thisTime);
disp(thisTimeString(end-7:end))
thisTime(5) = thisTime(5) + timeInterval;
end
Luffy
2012 年 7 月 6 日
If you just want a loop with only 3 different intervals maybe this crude method can help Clock15=char('12:00','12:15','12:30','12:45','13:00','13:15','13:30','13:45','14:00');
Clock30=char('12:00','12:30','13:00','13:30','14:00');
Clock60=char('12:00','13:00','14:00');
based on gui if u use popup menu use switch case and give either of Clock15/Clock30/Clock60 to Clock and write a loop,
for i = 1:size(Clock,1)
Clock(i,:)
end
Does this help you
Samer Husam
2012 年 7 月 6 日
6 件のコメント
Jan
2012 年 7 月 6 日
As far as I remember, the range must be declared as "A1:A1" for a single Excel cell.
What does "is its right each digit in one cell" mean? Could you please describe the problem more detailed?
Samer Husam
2012 年 7 月 6 日
Jan
2012 年 7 月 7 日
@Samer Husam: I guess, that this output is what you see in Excel, but it would be better if you explain this. I cannot guess, which code you have used to create this. Anyhow, Please read my comment and even better: "doc xlsread". There you find:
To specify a range (even a range of a single cell), include a colon character in the input string (e.g., 'D2:H4')
Therefore the range of a single cell must be "A1:A1".
Andrei Bobrov
2012 年 7 月 7 日
My variant is bad?
Samer Husam
2012 年 7 月 7 日
Samer Husam
2012 年 7 月 7 日
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!