How can I add 5 seconds to the output of the CLOCK function in MATLAB 7.9 (R2009b)?
3 ビュー (過去 30 日間)
古いコメントを表示
The CLOCK function returns a 1x6 vector. I want to compute "clock + 5 seconds".
For example:
>> clock
ans =
2009 10 6 14 18 9.125
I want to compute clock + 5 seconds, and get a vector [2009 10 5
12 40 01].
採用された回答
MathWorks Support Team
2009 年 10 月 14 日
To do this, you can use the DATENUM and DATEVEC function as an intermediaries:
second = [0 0 0 0 0 1];
datevec(datenum(clock + 5* second))
You can extend this idea to perform any arbitrary day arithmetic:
year = [1 0 0 0 0 0];
month = [0 1 0 0 0 0];
day = [0 0 1 0 0 0];
hour = [0 0 0 1 0 0];
minute = [0 0 0 0 1 0];
second = [0 0 0 0 0 1];
datevec(datenum(clock + 5*second + 4*month + 3*hour + 13*year));
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Dates and Time についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!