0% found this document useful (0 votes)
23 views4 pages

%trianglefunction Function End: 'Linewidth' 'Message Signal'

Mat2

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)
23 views4 pages

%trianglefunction Function End: 'Linewidth' 'Message Signal'

Mat2

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/ 4

%trianglefunction

function y=triangl(t)
y=(1-abs(t)).*(t>=-1).*(t<1);
end
%(ExampleSSB-SCdemfilt.m)
ts =1.e-4;
t=-0.04:ts:0.04;
Ta=0.01;fc=300;

m_sig=triangl((t+0.01)/0.01)-triangl((t-0.01)/0.01); %message signal TD


Lm_sig=length(m_sig);
Lfft=length(t);
Lfft=2^ceil(log2(Lfft));

M_fre=fftshift(fft(m_sig,Lfft)); % message signal FD


freqm=(-Lfft/2:Lfft/2-1)/(Lfft*ts);
B_m=150; %Bandwidth of the signal is B_m Hz.
h=fir1(40,B_m*ts);
s_dsb=m_sig.*cos(2*pi*fc*t); %DSB-SC modulated signal TD
Lfft=length(t);
Lfft=2^ceil(log2(Lfft)+1);
S_dsb=fftshift(fft(s_dsb,Lfft)); %DSB-SC modulated signal FD
L_1sb=floor(fc*ts*Lfft); % Lower Sideband
SSBfilt=ones(1,Lfft);
SSBfilt(Lfft/2-L_1sb+1:Lfft/2+L_1sb)=zeros(1,2*L_1sb);
S_ssb=S_dsb.*SSBfilt; % SSB-SC modulated signal FD (Tx)
freqs=(-Lfft/2:Lfft/2-1)/(Lfft*ts);
s_ssb=real(ifft(fftshift(S_ssb))); % SSB-SC modulated signal TD (Tx)
s_ssb=s_ssb(1:Lm_sig); % Receiver (Rx)

%Demodulation begins by multiplying with the carrier


s_dem=s_ssb.*cos(2*pi*fc*t)*2; % Demodulated signal TD (Rx)
S_dem=fftshift(fft(s_dem,Lfft)); % Demodulated signal FD (Rx)
%Using an ideal LPF with bandwidth 150Hz
s_rec=filter(h,1,s_dem); % Recover message TD (Rx)
S_rec=fftshift(fft(s_rec,Lfft)); % Recover message TD (Rx)

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_ssb);
axis(Trange);set(td2,'Linewidth',1.5);
title('SSB-SC Modulated Signal');
subplot(223);
td3=plot(t,s_dem);
axis(Trange);set(td3,'Linewidth',1.5);
title('after multiplying local carrier');
subplot(224);
td4=plot(t,s_rec);
axis(Trange);set(td4,'Linewidth',1.5);
title('Recovered 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_ssb));
axis(Frange);set(fd2,'Linewidth',1.5);
title('Upper sideband SSB-SC spectrum');
subplot(223);fd3=plot(freqs,abs(S_dem));
axis(Frange);set(fd3,'Linewidth',1.5);
title('Detector Spectrum');
subplot(224);fd4=plot(freqs,abs(S_rec));
axis(Frange);set(fd4,'Linewidth',1.5);
title('recovered spectrum');

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy