from Quadrature Amplitude Modulation (QAM) by imran shezad
Studying Phase Error Detection In Quadrature Amplitude Modulation (QAM)

M7.m
fc=1000;
fs=10000;
f1=150;
f2=300;
t=0:1/fs:((4/f1)-(1/fs));
x1=cos(2*pi*f1*t);
x2=cos(2*pi*f2*t);
%MODULATION
y=x1.*cos(2*pi*fc*t)+x2.*sin(2*pi*fc*t)
subplot(2,3,1);plot(x1);title('message signal 1');
subplot(2,3,2);plot(x2);title('message signal 2');
subplot(2,3,3);plot(y);title('QAM signal Transmitted');
%DEMODULATION
y1=y.*cos(2*pi*fc*t);
y2=y.*sin(2*pi*fc*t);
[b,a]=butter(10,2*pi*max(f1,f2)/fs);
x1_rec=filter(b,a,y1);
x2_rec=filter(b,a,y2);
subplot(2,3,4);plot(x1_rec);title('recovered message signal 1');
subplot(2,3,5);plot(x2_rec);title('recovered message signal 2');
%PHASE ERROR IN DEMODULATION
pe=pi/6;
y1_pe=y.*cos(2*pi*fc*t+pe);
x1_recpe=filter(b,a,y1_pe);
subplot(2,3,6);plot(x1_recpe);title('recovered message signal 1,PHASE ERROR=pi/6');

Contact us at files@mathworks.com