0% found this document useful (0 votes)
43 views3 pages

% (Exampleamdemfilt.M) : Y Triangl (T) Y (1-Abs (T) ) . (T - 1) . (T 1)

This document defines a triangle function and uses it to generate a message signal. It then generates an AM modulated signal by adding the message signal to a carrier signal. The AM signal is demodulated using rectification and filtering to recover the original message signal. Plots of the time domain and frequency domain signals are generated to illustrate the AM modulation and demodulation process.

Uploaded by

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

% (Exampleamdemfilt.M) : Y Triangl (T) Y (1-Abs (T) ) . (T - 1) . (T 1)

This document defines a triangle function and uses it to generate a message signal. It then generates an AM modulated signal by adding the message signal to a carrier signal. The AM signal is demodulated using rectification and filtering to recover the original message signal. Plots of the time domain and frequency domain signals are generated to illustrate the AM modulation and demodulation process.

Uploaded by

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

%trianglefunction

function y=triangl(t)
y=(1-abs(t)).*(t>=-1).*(t<1);
end

%(ExampleAMdemfilt.m)
ts=1.e-4;
t=-0.04:ts:0.04;
Ta=0.01; fc=500;
m_sig=triangl((t+0.01)/0.01)-triangl((t-0.01)/0.01);
Lm_sig=length(m_sig);
Lfft=length(t);
Lfft=2^ceil(log2(Lfft));
M_fre=fftshift(fft(m_sig,Lfft));
freqm=(-Lfft/2:Lfft/2-1)/(Lfft*ts);
B_m=150;
h=fir1(40,B_m*ts);

%AMsignal generated by adding a carrier to DSB-SC


s_am=(1+m_sig).*cos(2*pi*fc*t);
Lfft=length(t);
Lfft=2^ceil(log2(Lfft)+1);
S_am=fftshift(fft(s_am,Lfft));
freqs=(-Lfft/2:Lfft/2-1)/(Lfft*ts);

%Demodulation begins by using a rectifier


s_dem=s_am.*(s_am>0);
S_dem=fftshift(fft(s_dem,Lfft));

%Using an ideal LPF with bandwidth 150Hz


s_rec=filter(h,1,s_dem);
S_rec=fftshift(fft(s_rec,Lfft));

Trange=[-0.025 0.025 -2 2];


figure(1)
subplot(221);
td1=plot(t,m_sig);
axis(Trange);
set(td1,'Linewidth',1.5);
title('Message Signal');
subplot(222);
td2=plot(t,s_am);
axis(Trange);set(td2,'Linewidth',1.5);
title('AM Modulated Signal');
subplot(223);
td3=plot(t,s_dem);
axis(Trange);set(td3,'Linewidth',1.5);
title('Rectified signal without local carrier');
subplot(224);td4=plot(t,s_rec);
TrangeLow=[-0.025 0.25 -0.5 1]; %change Trange to Trangelow
axis(TrangeLow);set(td4,'Linewidth',1.5);
title('Detected Signal');

Frange=[-700 700 0 200];


figure(2)
subplot(221);
fd1=plot(freqm,abs(M_fre));
axis(Frange);set(fd1,'Linewidth',1.5);
title('Message Spectrum');
subplot(222);
fd2=plot(freqs,abs(S_am));
axis(Frange);set(fd2,'Linewidth',1.5);
title('AM Spectrum');
subplot(223);
fd3=plot(freqs,abs(S_dem));
axis(Frange);set(fd3,'Linewidth',1.5);
title('Rectified Spectrum');
subplot(224);
fd4=plot(freqs,abs(S_rec));
axis(Frange);set(fd4,'Linewidth',1.5);
title('Recovered Spectrum');

You might also like