Cronometer comparation for rally

1 回表示 (過去 30 日間)
Victório Mariani
Victório Mariani 2022 年 10 月 3 日
回答済み: Steven Lord 2022 年 10 月 3 日
Hi! I would like to compare the cronometer time with the time calculated, and output must be the time in seconds late or advanced. My code now is:
k=1;
v=44;
do=0.55;%Initial distance
tstart=datetime(0,0,0,0,30,0);%start time
w=datenum(tstart);%Convert double precision
d=input('Entre o valor do hodômetro:'); %Enter odometer value
a=((k*(d-do))/v); %Calculate the time
b=a*3600; %Convert to seconds
f=datenum(0,0,0,0,0,b); %Convert to double precision
T=w+f;
h=datestr(T,13)

回答 (1 件)

Steven Lord
Steven Lord 2022 年 10 月 3 日
I wouldn't use datetime here. Since your times are in units of seconds I'd probably store that data as a duration array instead.
A = rand(1000);
tic
s = svd(A);
t = toc;
timing = seconds(t)
timing = duration
0.25529 sec
You can do some arithmetic and relational operations on duration arrays.
tenth = seconds(0.1);
tookTooLong = timing > tenth % Did the call take longer than a tenth of a second?
tookTooLong = logical
1

カテゴリ

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

製品


リリース

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by