%
% A06A.m 
%
% Simple program to calculate the sin(t) at N values using a for loop.
% this is a super slow way of doing the calculation and should generally 
% not be used. It is an example of what NOT to do.
%
% Matlab-Monkey.com
% 12/30/2014

% tidy-up your workspace
clc         % clear command window
clear       % clear all variables
close all   % close all graphics windows


N = 1e4;            % set the number of point to 10^8

tic;                % start timer to measure computation time

i = 0;              % initialize counter                    
for t = linspace(0,2*pi,N)   % start of for loop
    i = i + 1;      % increment counter
    y(i) = sin(t);  % evaluate sin(t)
end                 % end of for loop

tElapsed = toc;     % measure elapsed time since timer started

% display elapsed time to command window
fprintf('elapsed time = %.3g seconds\n',tElapsed);
