필터 지우기
필터 지우기

how to calculate cpu time

조회 수: 3 (최근 30일)
kash
kash 2013년 3월 20일
I have a program
clc
if
%my program
else
disp('timed out')
end
my program consist of taking a snapshot through webcam
now i want to calculate the time,i.e the program must run for only 15 min,after 15 min if snapshot is taken it should be displayed as timed out

채택된 답변

Jan
Jan 2013년 3월 21일
You cannot interrupt your program from the outside, but you need to check a flag or value inside the program. Usually this is done in loops like this:
tic;
while toc < 900 % 15 minutes
takeYourSnapShot;
end

추가 답변 (1개)

Matt J
Matt J 2013년 3월 20일
편집: Matt J 2013년 3월 20일
See commands tic, toc, etime, now, cputime, etc...
  댓글 수: 3
Matt J
Matt J 2013년 3월 21일
for example
T0=cputime;
for i=1:1e6
if i==1e6/2
T=cputime-T0, %The time half way through the loop
i,
end
end
kash
kash 2013년 3월 21일
where i should insert my program

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by