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.

 Réponse acceptée

Jan
Jan le 20 Fév 2022
Modifié(e) : Jan le 21 Fév 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

Plus de réponses (0)

Catégories

En savoir plus sur Aerospace Blockset dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by