Inconsistent tic and toc

3 Ansichten (letzte 30 Tage)
Patrik Tegelberg
Patrik Tegelberg am 8 Nov. 2018
Beantwortet: Matt J am 8 Nov. 2018
I see a smooth frame rate, but when I measure the frame rate with tic and toc I frequently see unrealistic measurements, like less than one frame per second. I would definitely notice such a frame drop. Below is an extreme example measuring the time for one frame to 16 seconds, but I never saw any stutter.
Can someone help me to ever trust tic toc again, please.
Excerpt from code (simplified)
tic
while j < 1000 && ~quit
aaa = toc;
disp(['Frame rate = ' num2str(1 / aaa)])
if 1 / aaa < 1
disp(aaa)
toc
end
tic
pause(.001)
j = j + 1;
PlotStuff(j)
if strcmp(KEY_EVENT.Key, 'q') % I use a WindowsKeyPress callback.
quit = 1;
end
end
Excerpt from output
Frame rate = 40.9828
Frame rate = 44.1438
Frame rate = 41.395
Frame rate = 30.4108
Frame rate = 29.6011
Frame rate = 40.0793
Frame rate = 32.4089
Frame rate = 42.4079
Frame rate = 0.061352
16.2994
Elapsed time is 16.299732 seconds.
Frame rate = 39.5448
Frame rate = 32.8217
Frame rate = 32.0156
Frame rate = 41.5176

Antworten (1)

Matt J
Matt J am 8 Nov. 2018
Maybe do
PlotStuff(j); drawnow

Kategorien

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

Produkte


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by