Is there way to suppress the timer?
Show older comments
Hello, I am using tic and toc to measure the runtime of MATLAB's sort function for arrays of n lengths. In order to understand how the runtime increases with respect to how large n is I have plotted the runtime vs n. The thing is, it gets kind of troublesome to see MATLAB computing all the runtimes in the command window especially when n gets really large. Is there a way to suppress it like it was an output?
Accepted Answer
More Answers (1)
Micah Ackerman
on 30 Oct 2016
Edited: Walter Roberson
on 30 Oct 2016
Take a look at the following example and see if it helps. No need to just toc.
tic
%Summation
Dragonfly_data=load('dragonfly.dat');
Sum=0;
x=1;
while x<=100
Sum=Sum+Dragonfly_data(x);
x=x+1;
end
Sum; %Sum is suppressed, because the problem asks for the average.
%Average
Average=Sum/length(Dragonfly_data);
elapsedTime = toc;
fprintf('The average is %-0.3f Hertz.',Average)
fprintf('\nProblem 3 took %-.3f seconds to run.',elapsedTime)
1 Comment
Kai Xin
on 12 Nov 2018
This works without put the toc at the beginning of the code.
Categories
Find more on Performance and Memory in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!