how to calculate cpu time

2 Ansichten (letzte 30 Tage)
kash
kash am 20 Mär. 2013
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

Akzeptierte Antwort

Jan
Jan am 21 Mär. 2013
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

Weitere Antworten (1)

Matt J
Matt J am 20 Mär. 2013
Bearbeitet: Matt J am 20 Mär. 2013
See commands tic, toc, etime, now, cputime, etc...
  3 Kommentare
Matt J
Matt J am 21 Mär. 2013
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 am 21 Mär. 2013
where i should insert my program

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Entering Commands finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by