# Wrong output for phase demodulation

I tried to plot phase demodulated signal and original message signal but there is a significant difference between magnitudes of the message and demodulated signal. I have attached the code and the graph. Please help in pointing out the error.

Code

clear all; close all;
fm = 50;
fc = 1000;
fs = 4000;

t = 0:1/fs:0.1;
kp1 = pi/2;

m_t = 5*cos(2*pi*fm*t);

x_pm = cos(2*pi*fc*t + kp1*m_t);

x = pmdemod(x_pm,fc,fs,kp1);

figure(1);
plot(t,x_pm);
title('phase modulated signal');

figure(2);
plot(t,x,t,m_t);
title('message and demodulated signal');
legend('demodulated signal','message signal');


• Looks like 180-degree phase jumps – Ben Feb 29 '20 at 4:16
• @Ben What's the issue in the code? – A Q Feb 29 '20 at 4:28
• @AQ nothing – you just don't unwrap the phase. That's OK for some applications, and not OK for others. Notice how it's natural that the output phase range is $[-\pi;\pi]$. Again, maybe drop the 5 prefactor and see what happens... – Marcus Müller Feb 29 '20 at 9:24
• @MarcusMüller When I drop the 5 prefactor it works fine. I want to ask why does the demodulated wave not have the same amplitude as the message signal. – A Q Feb 29 '20 at 9:50
• I explained that. Phase wrapping. – Marcus Müller Feb 29 '20 at 10:21

You tell the phase demodulator that the signal has a maximum phase deviation of $$\pi/2$$, but then you actually use a signal with a phase deviation of $$5\pi/2$$ (due to the amplitude of the message signal). This doesn't make sense.
Note that even the most ideal phase demodulator cannot distinguish between $$\cos(2\pi f_ct+\phi(t))$$ and $$\cos(2\pi f_ct + \phi(t)+2k\pi)$$, $$k\in\mathbb{Z}$$.
• I first did that only when I used pmdemod but that decreased the amplitude of the demodulated signal to around 0.2 from 1. So, I thought I am doing something wrong. Can you write the code for getting the demodulated signal as message signal(with Am=5) by using unwrapping as said in comments as I not able to do. – A Q Feb 29 '20 at 10:34