필터 지우기
필터 지우기

run a for loop for 240 minutes

조회 수: 2 (최근 30일)
Momen AlManaseh
Momen AlManaseh 2022년 12월 14일
댓글: Bora Eryilmaz 2022년 12월 19일
Allow a foor loop to be run for 240 minutes.

답변 (1개)

Bora Eryilmaz
Bora Eryilmaz 2022년 12월 14일
편집: Bora Eryilmaz 2022년 12월 14일
% Runs for 5 seconds (i.e., 5/60 minutes)
T = 5/60; % minutes
ti = datetime('now');
tf = datetime('now');
while (minutes(tf-ti) < T)
% Do stuff
% Update current time
tf = datetime('now');
end
seconds(tf-ti) % Should be the same as T (in seconds), or
ans = 5.0000
minutes(tf-ti) % Should be the same as T (in minutes)
ans = 0.0833
But you can't rely on this for precise timing.
  댓글 수: 2
Momen AlManaseh
Momen AlManaseh 2022년 12월 16일
execusme sir, do you have any idea how i can computer the elapsed time in each iteration in for loop ?
Bora Eryilmaz
Bora Eryilmaz 2022년 12월 19일
You can use the tic/toc commands within the while loop:
tic
% Do stuff
elapsedTime = toc
elapsedTime = 0.0036

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by