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.

 Risposta accettata

Jan
Jan il 20 Feb 2022
Modificato: Jan il 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

Più risposte (0)

Categorie

Scopri di più su Aerospace Blockset in Centro assistenza e File Exchange

Richiesto:

il 20 Feb 2022

Modificato:

Jan
il 21 Feb 2022

Community Treasure Hunt

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

Start Hunting!

Translated by