필터 지우기
필터 지우기

Does anyone know how to do this problem

조회 수: 3 (최근 30일)
Ethan
Ethan 2014년 11월 5일
댓글: David Sanchez 2014년 11월 5일
MATLAB has timing functions that allow your program to monitor how much time has elapsed. These are called tic and toc. The function toc returns the amount of time since the last tic. Use a while loop to do the following for a total of 4 seconds. Every 0.3 seconds print, using fprintf, the message “The elapsed time is:” followed by the elapsed time.
  댓글 수: 1
Geoff Hayes
Geoff Hayes 2014년 11월 5일
편집: Geoff Hayes 2014년 11월 5일
Ethan - see tic and toc for details. Calling tic will start a stopwatch timer, and calling toc will return the elapsed time since the stopwatch timer was started. Note that toc can refer to a specific stopwatch timer. Pay particular attention to the third example given in the toc link.

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

답변 (1개)

David Sanchez
David Sanchez 2014년 11월 5일
tic
lim = 0.3;
N=1;
while toc<.61
%%%%%
a=rand;%whatever your program does here
%%%%%
tmp = toc;
if tmp>lim
fprintf('The elapsed time is %g\n', tmp)
N=N+1;
lim=lim*N;
end
end
  댓글 수: 1
David Sanchez
David Sanchez 2014년 11월 5일
obviously, you chane .61 by 4 to cover up your case
...
while toc < 4
...

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by