% file:      	am.m, (c) Matthew Roughan, Wed Oct  6 2004
%
N = 1000; x = (1:N)/N;
f = 0.3 * sin(pi*x) - 0.4 * sin(pi*3*x) + 0.2 * sin(pi*4*x) + 0.2 * sin(pi*7*x);
carrier_freq = 17;
carrier = cos(2*pi*carrier_freq*x);
am_signal = carrier .* abs(f);

figure(1)
hold off
plot(x, f, 'b', 'linewidth', 3);
hold on
plot([0 1], [0 0], ':', 'linewidth', 3);
set(gca, 'xtick', [], 'ytick', [], 'fontsize', 24, 'linewidth', 3);
ylabel('signal, x(t)');
set(gcf, 'PaperUnits', 'centimeters', 'PaperPosition', [0 0 20 5])
print('-depsc', 'Plots/am_1.eps');

figure(2)
hold off
plot(x, carrier, 'g', 'linewidth', 3);
hold on
plot([0 1], [0 0], ':', 'linewidth', 3);
set(gca, 'xtick', [], 'ytick', [], 'ylim', [-1.2 1.2], 'fontsize', 24, 'linewidth', 3);
ylabel('carrier');
set(gcf, 'PaperUnits', 'centimeters', 'PaperPosition', [0 0 20 5])
print('-depsc', 'Plots/am_2.eps');

figure(3)
hold off
plot(x, am_signal, 'g', 'linewidth', 3);
hold on
plot([0 1], [0 0], ':', 'linewidth', 3);
plot(x, [f; -f], 'b', 'linewidth', 3);
set(gca, 'xtick', [], 'ytick', [], 'ylim', [-1.2 1.2], 'fontsize', 24, 'linewidth', 3);
ylabel('moulated');
set(gcf, 'PaperUnits', 'centimeters', 'PaperPosition', [0 0 20 5])
print('-depsc', 'Plots/am_3.eps');

figure(4)
hold off
plot(x, carrier .* ( abs(1 + f)), 'g', 'linewidth', 3);
hold on
plot([0 1], [0 0], ':', 'linewidth', 3);
plot(x, [1+f; -1-f], 'b', 'linewidth', 3);
set(gca, 'xtick', [], 'ytick', [], 'fontsize', 24, 'linewidth', 3);
ylabel('moulated');
set(gcf, 'PaperUnits', 'centimeters', 'PaperPosition', [0 0 20 5])
print('-depsc', 'Plots/am_4.eps');


