Code
Code
Code
clear;
%% Transmitter
% Step 1: Read audio file and plot in time and frequency domain
[signal, Fs] = audioread('eric.wav');
t = (0:length(signal)-1) / Fs;
figure;
subplot(1,2,1);
plot(t, signal);
xlabel('Time (s)');
ylabel('Amplitude');
title('Audio Signal in Time Domain');
signal_freq = fftshift(fft(signal));
f = linspace(-Fs/2, Fs/2, length(signal_freq));
subplot(1,2,2);
plot(f, abs(signal_freq));
xlabel('Frequency (Hz)');
ylabel('Magnitude');
title('Audio Signal in Frequency Domain');
% Step 5: Modulate carrier with filtered signal for DSB-TC and DSB-SC
t_resampled = (0:length(signal_resampled)-1) / Fs_new;
carrier = cos(2*pi*fc*t_resampled);
% DSB-TC modulation
A = 2 * max(signal_resampled);
dsbtc_modulated = carrier .* (A + signal_resampled);
% DSB-SC modulation
dsbsc_modulated = carrier .* signal_resampled;