You are on page 1of 11

EEE 4560

ASSIGNMENT SUBMISSION
AL-AMIN ALVI , ID: 132477, SECTION: A-2

1.
T=0.1;
fs=8000;
t=0:1/fs:T;
Vm=1;
fm=10;
m=Vm*sin(2*pi*fm*t);
fc=300;
v=ammod(m,fc,fs);
mr=amdemod(v,fc,fs);
figure(1);
subplot(2,1,1);
plot(t,m);
subplot(2,1,2);
plot(t,v);
figure(2)
subplot(2,1,1);
plot(t,m);
subplot(2,1,2)
plot(t,mr);

2.
%%
%sampling the signal 100 times per second, for 2 seconds.
Fs=100;
t=[0:2*Fs+1]'/Fs;
Fc=10;
x=sin(2*pi*t);
%modulating x using single and double sideband AM
ydouble=ammod(x,Fc,Fs);
ysingle=ssbmod(x,Fc,Fs);
%Compute spectra of both modulated signals.
zdouble=fft(ydouble);
zdouble=abs(zdouble(1:length(zdouble)/2+1));
frqdouble=[0:length(zdouble)-1]*Fs/length(zdouble)/2;
zsingle=fft(ysingle);
zsingle=abs(zsingle(1:length(zsingle)/2+1));
frqsingle=[0:length(zsingle)-1]*Fs/length(zsingle)/2;
%plotting spectra of both modulated signals.
figure;
subplot(2,1,1);
plot(frqdouble,zdouble);
title('Spectrum of double-sideband signal');
subplot(2,1,2);
plot(frqsingle,zsingle);
title('Spectrum of a single-sideband signal');

3.
%%
clc;
close all;
clear all;
fs=2000;
f=5;
fc=50;
N=2000;
t=(1:N)/fs;
%AM Modulation%
w=2*pi*fc*t;
w1=2*pi*f*t;
vc=sin(w);
figure(1);
plot(t,vc);
vsig=sin(w1);
figure(2);
plot(t,vsig);
vm=(1+0.5*vsig).*vc;
figure(3);
plot(t,vm);
%AM Demodulation%
v1=vc.*vm;
wn=0.02;
[b,a]=butter(4,wn);
vout=filter(b,a,v1);
figure(4);
plot(t,vout);

4.
clear all;
close all;
clc;
%%Frequency Modulation of Triangular Signal
t=-0.04:1.e-4:0.04;
Ta=0.01;
fc=200;
msg=msg1(t,Ta);
%%Modulation
kf=300*pi;
m_int=kf*1.e-4*cumsum(msg);
fm=cos(2*fc*pi*t+m_int);
%%Demodulation (using differentiator)
dem=diff(fm);
dem=[0,dem];
rect_dem=dem.^2;
%%Filtering out High Frequencies
N=80;
Wn=1.e-2;
a=fir1(N,Wn);
b=1;
rec=filter(a,b,rect_dem);
%%Finding frequency response of signal
fl=length(t);
fl=2^ceil(log2(fl));
f=(-fl/2:fl/2-1)/(fl*1.e-4);
mF=fftshift(fft(msg,fl));
fmF=fftshift(fft(fm,fl));

rect_demF=fftshift(fft(rect_dem,fl));
recF=fftshift(fft(rec,fl));
%%Plotting signals in time domain
figure;
subplot(2,1,1);
plot(t,msg);
title('Message Signal');
xlabel('{\it t} (sec)');
ylabel('m(t)');
grid;
subplot(2,1,2);
plot(t,fm);
title('FM');
xlabel('{\it t} (sec)');
ylabel('FM');
grid;
figure;
subplot(2,1,1);
plot(t,rect_dem);
title('Rectified FM');
xlabel('{\it t} (sec)');
ylabel('dem');
grid;
subplot(2,1,2);
plot(t,rec);
title('Recovered Signal');
xlabel('{\it t} (sec)');
ylabel('m(t)');
grid;
%%Plotting frequency response of signal
figure;
subplot(2,2,1);
plot(f,abs(mF));
title('Frequency response of MSG');
xlabel('f(Hz)');
ylabel('M(f)');
grid;
axis([-600 600 0 200]);
subplot(2,2,2);
plot(f,abs(fmF));
title('Frequency response of FM');
xlabel('f(Hz)');
ylabel('C(f)');
grid;
axis([-600 600 0 300]);

subplot(2,2,3);
plot(f,abs(rect_demF));
title('Frequency response of REctified FM');
xlabel('f(Hz)');
ylabel('DSBSC(f)');
grid;
axis([-600 600 0 10]);
subplot(2,2,4);
plot(f,abs(recF));
title('Frequency response of Recovered Signal');
xlabel('f(Hz)');
ylabel('M(f)');
grid;
axis([-600 600 0 10]);

5.
%%Function of Msg(tri)

function a = msg1(t,Ta)
t1=-0.02:1.e-4:0;
t2=0:1.e-4:0.02;
m1=1-abs((t1+Ta)/Ta);
m1=[zeros([1 200]),m1,zeros([1 400])];
m2=1-abs((t2-Ta)/Ta);
m2=[zeros([1 400]),m2,zeros([1 200])];
a=m1-m2;
end

6.

clc;
clear all;
close all;
Ac=2;
fc=0.5;
Am=.5;
fm=.05;
Fs=100;
ka=1;
t=[0:0.1:100];
ct=Ac*cos(2*pi*fc*t);
mt=Am*cos(2*pi*fm*t);
AM=ct.*(1+ka*mt);
plot(AM, 'b');
hold on;
envelope = abs(hilbert(AM));
plot(envelope, 'r');
hold off

3.

You might also like