m = 1000;
n = 1;
k = 0;
for logn = 0 : 12
  clear a
  tic;
  for i = 1 : m
    for j = 1 : n
      a(i,j) = sin ( i * pi / m ) * exp ( j * pi / n );
    end
  end
  k = k + 1;
  x(k) = m * n;
  y(k) = toc;
  n = n * 2;
end

plot ( log(x), log(y), 'b-*', 'LineWidth', 2, 'MarkerSize', 10 );

grid on
xlabel ( 'Number of matrix entries' );
ylabel ( 'TicToc Time in Seconds' );
title ( 'Time versus matrix size' );
axis equal

m = 1000;
n = 1;
k = 0;
for logn = 0 : 12
  k = k + 1;
  rate = x(k) / y(k);
  fprintf ( 1, '%4d  %4d  %8d  %f  %8.2g\n', m, n, x(k), y(k), rate )
  n = n * 2;
end
