Professional Documents
Culture Documents
T_sample = 0.0001;
f_sample = 1/T_sample;
N_sample = 16000;
t0 = 0.1;
fc = 250;
t = -((N_sample/2)-1)*T_sample:T_sample:(N_sample/2)*T_sample;
m = 0*t;
for i=1:N_sample
if(0<=(i-(N_sample/2))*T_sample)&&(((i-(N_sample/2))*T_sample)<=t0);
m(i) = sinc(100*(i-(N_sample/2))*T_sample);
end
end
subplot(4,4,1);
plot(t,m);
title('Message signal with t0 = 0.1');
xlabel('Time(Sec)');
ylabel('Amplitude');
axis([-0.8 0.8 -2 2]);
M = fft(m)*T_sample;
freq = (0:N_sample-1)*f_sample/N_sample;
Mshift = fftshift(M);
fshift = (-N_sample/2:N_sample/2-1)*(f_sample/N_sample);
subplot(4,4,5);
plot(fshift,abs(Mshift));
title('Message spectrum M(f)');
xlabel('Frequency (Hz)');
ylabel('Magitude');
axis([-500 500 0 0.02]);
subplot(4,4,9);
plot(fshift,angle(Mshift));
axis([-500 500 -pi pi]);
title('Phase of Message Spectrum');
xlabel('Frequency (Hz)');
m2 = f_sample*ifft(fftshift(Mshift));
subplot(4,4,13);
plot(t,m2);
title('Reconstructed m(t) with t0 = 0.1');
xlabel('Time(sec)');
axis([-0.8 0.8 -2 2]);
Problem 3.4:
MATLAB Code:
T_sample = 0.0001;
f_sample = 1/T_sample;
N_sample = 16000;
t0 = 0.1;
t = -((N_sample/2)-1)*T_sample:T_sample:(N_sample/2)*T_sample;
m = 0*t;
for i=1:N_sample
if(-t0<=(i-(N_sample/2))*T_sample)&&(((i-(N_sample/2))*T_sample)<=t0);
m(i) = sinc(100*(i-(N_sample/2))*T_sample);
end
end
subplot(2,3,1);
plot(t,m);
title('Original Message signal m(t)');
xlabel('Time(Sec)');
ylabel('Amplitude');
axis([-0.8 0.8 -2 2]);
fc = 250;
for i=1:N_sample
c(i) = cos(2*pi*fc*(i-(N_sample))*T_sample);
end
subplot(2,3,2);
plot(t,c);
title('Carrier signal with c(t)');
xlabel('Time(Sec)');
ylabel('Amplitude');
axis([-0.8 0.8 -2 2]);
a = 0.8;
u = (1+a*m).*c;
subplot(2,3,3);
plot(t,u);
title('Modulated signal with u(t)');
xlabel('Time(Sec)');
ylabel('Amplitude');
axis([-0.8 0.8 -2 2]);
%Demodulation
s1 = u.*c;
b = fir1(30,0.02,'low',chebwin(31,3));
output = filtfilt(b,1,s1);
subplot(2,3,4);
plot(t,output);
title('Reconstructed signal mr(f)');
xlabel('Frequency (Hz)');
ylabel('Magitude');
axis([-0.8 0.8 -2 2]);
S1 = fft(s1)*T_sample;
freq = (0:N_sample-1)*f_sample/N_sample;
Sshift = fftshift(S1);
fshift = (-N_sample/2:N_sample/2-1)*(f_sample/N_sample);
subplot(2,3,5);
plot(fshift,abs(Sshift));
title('Received Signal spectrum R(f)');
xlabel('Frequency (Hz)');
ylabel('Magitude');
axis([-500 500 0 0.02]);
MR = fft(output)*T_sample;
freq = (0:N_sample-1)*f_sample/N_sample;
Sshift = fftshift(MR);
fshift = (-N_sample/2:N_sample/2-1)*(f_sample/N_sample);
subplot(2,3,6);
plot(fshift,abs(Sshift));
title('Reconstructed message Signal spectrum MR(f)');
xlabel('Frequency (Hz)');
ylabel('Magitude');
axis([-500 500 0 0.02]);
Part3:
The frequency domain spectrum of reconstructed message signal is given at (2,3,6) position of
above figure. It is almost same as of original signal anyhow there is some noise.