etime input arguments, what do they mean?

Hi
I am using etime for a piece of code:
start=clock
limit=10
while etime(clock,start) < limit
rotate(xxxx)
end
I am rotating something. My question is though, seeing as we have start=clock i.e. they are equivalent, I am assuming elapsed time is 0, and that while elapsed time = 0 < limit, the rotation will take place?
Have I understood this correctly?
Thanks.

 Accepted Answer

Jan
Jan on 20 Feb 2022
Edited: Jan on 21 Feb 2022
Take a look into the documentation:
doc clock
doc etime
Then run some own tests: type this in the command window:
clock
% wait a little bit
clock
You see, clock replies the current time and date as a [1 x 6] vector.
According to the help text, etime replies the number of seconds between two date/time vectors.
The line "start=clock" stores the output of the function clock in the variable start. Comparing the output of the next call of clock with the value of start replies the elapsed time.
In the shown code this means, that the loop runs, until 10 seconds have past.
See this online tutorial to learn the basics: https://www.mathworks.com/learn/tutorials/matlab-onramp.html

More Answers (0)

Categories

Find more on Aerospace Blockset in Help Center and File Exchange

Tags

Asked:

on 20 Feb 2022

Edited:

Jan
on 21 Feb 2022

Community Treasure Hunt

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

Start Hunting!