0% found this document useful (0 votes)
2 views

MatlabCode

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

MatlabCode

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Vm1=10//magnitude of modulating signal 1

Vm2=15//magnitude of modulating signal 2

Vc=20//magnitude of carrier signal

fs=100//sampling frequency

fc=10

fm1=3

fm2=5

t=[0:1/fs:3]//descretising time axis

vm1=Vm1.*cos(2.*fm1.*%pi.*t)//modulating signal 1

vm2=Vm2.*cos(2.*fm2.*%pi.*t)//modulating signal 2

vm=vm1+vm2//final modulating signal

figure(1)

subplot(3,1,1)

plot(t,vm)

xlabel("t")

ylabel("vm")

title("Modulating Signal")

vc=Vc.*cos(2*fc.*%pi.*t)//carrier signal

subplot(3,1,2)

plot(t,vc)

xlabel("t")

ylabel("vc")

title("Carrier Signal")

vam=(Vc+vm).*cos(2.*fc.*%pi.*t)//multi-tone AM signal - two-tone AM signal

subplot(3,1,3)//for plotting multiple plots


plot(t,vam)//plotting modulated signal

xlabel("t") ;

ylabel("vam");

title("AM Signal in Time Domain")

l=length(t)//total no.of samples

f=[-l/2:(l/2)-1].*fs/l//discretising frequency domain

y=abs(fftshift(fft(vam)))//absolute fft of amplitude modulated signal

figure(2)

subplot(2,1,1)

plot(f,y)//plot fft in frequency domain

xlabel("f")

ylabel("Magnitude")

title("AM Spectrum")

//title(fft)//to give a title to the plot

demod=vam.*vc//local oscillator

//x=abs(fft(demod))

//subplot(3,1,2)

//plot(f,x)

lpf=[ones(1,4.*fm2),zeros(1,l-4.*fm2)]

recov=abs(fft(demod)).*lpf

subplot(2,1,2)

plot (t,ifft(recov))

xlabel("t")

ylabel("v_demod")

title("Demodulated Signal")

You might also like