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
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 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

タグ

タグが未入力です。

製品


リリース

R2009b

Community Treasure Hunt

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

Start Hunting!

Translated by