clear
%
%  Calculate the usual way, and plot in blue.
%
m = 1000;
a = zeros ( m, m );
x = zeros ( 11 );
y = zeros ( 11 );
n = 1;
k = 0;
for logn = 0 : 10
  tic;
  for i = 1 : m
    for j = 1 : n
      a(i,j) = sin ( i * pi / m ) * cos ( j * pi /n );
    end
  end
  k = k + 1;
  x(k) = m * n;
  y(k) = toc;
  n = n * 2;
end
plot ( x, y, 'b-*', 'LineWidth', 2, 'MarkerSize', 10 );
%
%  Repeat the calculation.  Plot in red this time.
%
hold on

m = 1000;
n = 1;
k = 0;
for logn = 0 : 10
  tic;
  s = sin ( ( 1 : m ) * pi / m );
  c = cos ( ( 1 : n ) * pi / n );
  a = s' * c;
  k = k + 1;
  x(k) = m * n;
  y(k) = toc;
  n = n * 2;
end
plot ( x, y, 'r-*', 'LineWidth', 2, 'MarkerSize', 10 );


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

