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.

 채택된 답변

Jan
Jan 2022년 2월 20일
편집: Jan 2022년 2월 21일

0 개 추천

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Aerospace Blockset에 대해 자세히 알아보기

태그

질문:

2022년 2월 20일

편집:

Jan
2022년 2월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by