% illustrate that amplitude modulation produces sidebands
% make a small modulation of a cosine wave
eps = 0.03;   % size of the ampltude modulation is 3 percent
nu1 = 10.0;   % frequency of carrier
nu2 = 1.0;    % frequency of modulation
% number of points in the vector
N = 2048;  % use a power of two to make fourier transform easier
% create 10 periods of the modulation
tstep = 10*2*pi/N;
t = [0:N-1]*tstep;
% use .* operator to multiply each element in the vectors
A = (1.0+eps*cos(nu2*t)).*cos(nu1*t);
plot(t,A);
pause;

% take a fast fourier transform
FA = fft(A)/1024;
% create the frequency axis;
faxis = pi/tstep*linspace(0,1,1024);
% Plot single-sided amplitude spectrum.
plot(faxis,abs(FA(1:1024)));
pause;

% see what MatLab will do with symbolic variables
clear  % not sure if I need this but probably good to clear old variables
syms nu1 nu2 t eps
A = (1.0+eps*cos(nu2*t)).*cos(nu1*t);
simple(A)
% the result of this includes the sum and difference frequencies listed
% under "combine(trib)" but I don't see how to access this result directly
pause;
