clear close all clc % Amplitude Modulation % I. Tone modulation t = linspace(-1,1,1000); fc = 10; fm = 1; Ac = 1; Am = 1; ka = 0.5; c = Ac*cos(2*pi*fc*t); % carrier m = Am*cos(2*pi*fm*t); % message mu = Am*ka; % modulation factor env = Ac*(1 + ka*m); % envelope s = env .* c; % modulation signal subplot(311); plot([-1, 1], [0 0], 'k', t, m, 'k', 'LineWidth', 1.5); axis([-1, 1, -1-0.25, 1+0.25]); set(gca, 'FontSize', 14, 'Box', 'off', 'LineWidth', 1.5); xlabel('Time'); ylabel('Magnitude'); title('Message') subplot(312); plot([-1, 1], [0 0], 'k', t, c, 'k', 'LineWidth', 1.5); axis([-1, 1, -1-0.25, 1+0.25]); set(gca, 'FontSize', 14, 'Box', 'off', 'LineWidth', 1.5); xlabel('Time'); ylabel('Magnitude'); title('Carrier'); subplot(313); plot([-1, 1], [0, 0], 'k', t, s, 'b', t, env, 'r', 'LineWidth', 1.5); axis([-1, 1, -1-mu-0.25, 1+mu+0.25]); set(gca, 'FontSize', 14, 'Box', 'off', 'LineWidth', 1.5); title(['Amplitude Modulation. mu = ', num2str(mu)], 'Interpreter', 'tex'); xlabel('Time'); ylabel('Magnitude'); % II. AM dt = 1/128; N = 512; t = -1:dt:1; fc = 10; Ac = 1; ka = 0.35; c = Ac*cos(2*pi*fc*t); % carrier m = cos(2*pi*t) - 1/3*cos(6*pi*t - pi/3); % message signal env = Ac*(1 + ka*m); % envelope s = env .* c; % modulation signal subplot(311); plot([-1, 1], [0 0], 'k', t, m, 'b', 'LineWidth', 1.5); axis([-1, 1, -1-0.35, 1+0.35]); set(gca, 'FontSize', 14, 'Box', 'off', 'LineWidth', 1.5); xlabel('Time'); ylabel('Magnitude'); title('Message') subplot(312); plot([-1, 1], [0 0], 'k', t, c, 'b', 'LineWidth', 1.5); axis([-1, 1, -1-0.25, 1+0.25]); set(gca, 'FontSize', 14, 'Box', 'off', 'LineWidth', 1.5); xlabel('Time'); ylabel('Magnitude'); title('Carrier'); subplot(313); plot([-1, 1], [0, 0], 'k', t, s, 'b', t, env, 'r', 'LineWidth', 1.5); axis([-1, 1, -1-0.5, 1+0.5]); set(gca, 'FontSize', 14, 'Box', 'off', 'LineWidth', 1.5); title(['Amplitude Modulation. ka = ', num2str(ka)], 'Interpreter', 'tex'); xlabel('Time'); ylabel('Magnitude'); dt = 1/32; N = 64; t = -1:dt:1-dt; fc = 10; Ac = 1; ka = 0.35; c = Ac*cos(2*pi*fc*t); % carrier m = cos(2*pi*t) - 1/3*cos(6*pi*t - pi/3); % message signal env = Ac*(1 + ka*m); % envelope s = env .* c; % modulation signal % frq = (0:N-1)/N/dt; frq = (-N/2:N/2-1)/N/dt; M = fftshift(fft(m, N)); S = fftshift(fft(s, N)); subplot(211); stairs(frq-1/N/dt/2, abs(M)); subplot(212); stairs(frq-1/N/dt/2, abs(S));