% Fs is the sampling rate.
Fs = 8000;
% Defining carrier frequency 'Fc'.
Fc = 500;
% Generating a carrier signal 'Cs' through linearly spaced vectors.
Cs = cos(linspace (0,2*pi*Fc,Duration*8000));
% Creating an analog output object 'ao'.
ao = analogoutput('winsound');
% Adding a hardware channel to an analog output object 'ao'.
channel_2 = addchannel(ao,1);
% Applying the amplitude modulation concept to variable 'x' by multiplying
% it with carrier signal 'Cs' after taking transpose.
% AmpMod = amod(x,Fc,Fs,'amdsb-sc',num,den);(ALTERNATIVE APPROACH)
AmpMod = x'.*Cs;
% Demodulating the signal.
% DeAmpMod = (1/2).*(ademod(AmpMod,Fc,Fs,'amdsb-sc',num,den));
% (ALTERNATIVE APPROACH)
DeAmpMod = AmpMod.*Cs;
% Designing butterworth low pass filter.
[num,den] = butter(2,.8);
FilteredOutput = filter(num,den,DeAmpMod);
% Plotting the input speech signal 'data'.
subplot(2,2,1);
axis normal;
plot(data);
grid on;
title('Initial Speech Signal');
xlabel('Samples');
ylabel('Speech Signal');
% Plotting the modulated speech signal 'AmpMod'.
subplot(2,2,2);
axis normal;
plot(AmpMod);
title('Modulated Speech Signal')
xlabel('Samples')
ylabel('Modulated Signal')
% Plotting the demodulated speech signal 'DeAmpMod'.
subplot(2,2,3)
axis normal
plot(DeAmpMod);
grid on
title('Demodulated Speech Signal')
xlabel('Samples')
ylabel('Demodulated Signal')
% Plotting the filtered speech signal 'FilteredOutput'.
subplot(2,2,4)
axis normal
plot(FilteredOutput)
grid on
title('Received Signal At Output')
xlabel('Samples')
ylabel('Filtered Signal')
评论0