%profile on

for k = [1000 10000 10^7]
  disp(['Vector size: ', num2str(k)]);
%  clear;
% Fill b with square roots of 1 to 1000, 10000, 10^7 using a for loop
  tic;
%  b = zeros(1,k);
  for i = 1:k
    b(i) = sqrt(i);
  end
  t_l = toc;
  disp(['  Time taken for loop   method is  ', num2str(t_l)]);
  
% Fill b with square roots of 1 to 1000, 10000, 10^7 using a vector
  tic;
  a = 1:k;
  b = sqrt(a);
  t_v = toc;
  disp(['  Time taken for vector method is  ', num2str(t_v)]);
  disp(['  Ratio loop/vector is  ', num2str(t_l/t_v)]);
  fprintf('\n');
end
%profile viewer
