Write a Matlab Code for PM transmitter and receiver (for a sinusoid message signal) . If the carrier frequency offset is set to 10 Hz (in the Matlab code deltaf = 10) the demodulator implemented in the m-file still works pretty well with this frequency offset. Explain why. Note, at higher frequency offsets (e.g., 100 Hz) the performance suffers noticeable distortion
Note:
Saperate Code for Transmitter and Reciever
clc;close all;clear all;
f=100; fc=1000;m=0.5;fs=16384;
t=[0:1/fs:0.05];
%Modulating signal
signal=sin(2*pi*f*t);
subplot(421)
plot(t,signal,'r')
title('Modulating signal vs time')
xlabel('t')
ylabel('signal')
A=abs(min(signal))/m;
carrier1=sin(2*pi*fc*t)
%modulated signal
x=(signal+A).*carrier1;
subplot(422)
plot(t,x,'m')
title('Modulated signal vs time')
xlabel('t')
ylabel('x')
%Demodulated signal
delta=0;phi=0;
carrier2=sin((2*pi*(fc+delta).*t)+phi);
x1=x.*carrier2
b=fir1(24,500/fs)
x_demod=conv2(x1,b,'same')
subplot(423)
plot(t,x_demod,'b')
title('Demodulated signal vs time')
xlabel('t')
ylabel('x')
%Frequency domain plots
[S1]=ft(signal,fs);
[C1]=ft(carrier1,fs);
[X]=ft(x,fs);
subplot(424)
plot([0:length(S1)-1],S1,'r')
xlim([0,2000])
title('message signal in frequency domain')
xlabel('f')
ylabel('S1')
subplot(425)
plot([0:length(C1)-1],C1,'g')
xlim([0,2000])
title('Carrier at transmitter end in frequency domain')
xlabel('f')
ylabel('C1')
subplot(426)
plot([0:length(X)-1],X,'m')
xlim([0,2000])
title('modulated signal in frequency domain')
xlabel('f')
ylabel('X')
C2=ft(carrier2,fs)
subplot(427)
plot([0:length(C2)-1],C2,'g')
xlim([0,2000])
title('Carrier at the receiver end in frequency domain')
xlabel('f')
ylabel('C2')
S2=ft(x_demod,fs)
subplot(428)
plot([0:length(S2)-1],S2,'r')
xlim([0,2000])
title('Demodulated signal in frequency domain')
xlabel('f')
ylabel('S2')
Comments
Leave a comment