tocStop the internal timer
toctic.dt = toctic.toc(t)t should have been obtained previously by calling t = tic. Otherwise, the time reported will be incorrect.t and the time when toc(t) is called.dt = toc(t)t should have been obtained previously by calling t = tic. Otherwise, the time reported will be incorrect.t and the time when toc(t) is called.tic is called.tic
% Each of the matrices has 1,000,000 entries.
a = rand(1000,1000);
b = rand(1000,1000);
% Time taken to create the matrices.
toc
C = a'.*b';
% Time taken to create the matrices and to perform the multiplication.
toc
Time elapsed: 3.077404e-02 seconds.
Time elapsed: 8.709546e-01 seconds.
n equations on an iPad Pro 11-inch (2nd generation).clear
t = zeros(1,100);
for n = 1:100
a = rand(n,n);
b = rand(n,1);
tic;
x = a\b;
t(n) = toc;
end
plot(t)
xlabel('n');
ylabel('Time needed');
title('Time required to solve a system of n linear equations')
