📄 acomp_5_1.m
字号:
%16_QAM symbol sequence of 2000 symbols and plot the constellation
M=4; %M^2-QAM
temp_M=-(M-1):2:(M-1);
for i=1:M
for k=1:M
QAM(i,k)=temp_M(i)+j*temp_M(k);
end
end
QAM=QAM(:).'; %Alphabet vector
index=randint(1,2000,[1 M^2]);
sym=QAM(index); %Random QAM symbol sequence
over=16;
pulse=rcosine(1,over,'normal',0.35);
[trash,pos]=max(pulse);
sig=kron(sym,[1 zeros(1,over-1)]);
sig=filter(pulse,1,sig);
sig=sig(pos:end);
figure(1);plot(real(sig(1:800)));
xlabel('Time[s]');ylabel('Amplitude');
title('Pulse Shaping Signal ');
grid;
w_c=0.4;
r=2*real(sig.*exp(j*w_c*pi*(0:length(sig)-1)));
figure(2);plot(r(1:800));
xlabel('Time[s]');ylabel('Amplitude');
title('A Piece of the Passband Signal');
grid;
W=linspace(-pi,pi,1024);
R=freqz(r(1000:2023),1,W);
R=R./max(abs(R));
figure(3);subplot(211);
plot(W/pi,abs(R));
xlabel('Hz');ylabel('dB');
title('Spectrum of the Passband Signal ');
grid;
y=r.*exp(-j*w_c*pi*(0:length(r)-1));
f=remez(50,[0 0.2 0.3 1],[1 1 0 0]);
F=freqz(f,1,W);
hold on;
plot(W/pi,abs(F),'r','LineWidth',2);
y=filter(f,1,y);
y=y(26:end);
Y=freqz(y(1000:2023),1,W);
Y=Y./max(abs(Y));
figure(3);subplot(212);plot(W/pi,abs(Y));grid;
xlabel('Hz');ylabel('dB');
title('Frequency Response of the Lowpass Filter and Signal which is I/Q Downconverted');
axis([-1 1 0 1.1]);
figure;
hold on;
plot(y(1+over:over:end),'*','MarkerSize',8);hold on;
ph=(0:5:360)*pi/180; plot(3*1.414*cos(ph),3*1.414*sin(ph),'c');
hold on;
plot([-4 4], [0 0], 'k:',[0 0], [-4 4], 'k:');
hold off; axis equal;
axis([-6 6 -6 6]);grid;
xlabel('Re[16qam]');ylabel('Im[16qam]');
title('16-QAM Constellation');
hold off;
%h=remez(100,[0.02 0.98],[1 1],'Hilbert');
%f2=0.5*([zeros(1,50) 1 zeros(1,50)]+j*h);
%pos=51;
f=remez(50,[0 0.2 0.3 1],[1 1 0 0]);
f2=f.*exp(j*w_c*pi*(0:length(f)-1));
pos=26;
F2=freqz(f2,1,W);
figure(3);subplot(212);cla;
subplot(211);hold on;
plot(W/pi,abs(F2),'r','LineWidth',2);
grid on;
title('Frequency Response of the Complex Passband Filter');
hold off;
y=filter(f2,1,r);
y=y(pos:end);
Y=freqz(y(1000:2023),1,W);
Y=Y./max(abs(Y));
subplot(212);hold on;
plot(W/pi,abs(Y));
y=y.*exp(-j*w_c*pi*(0:length(y)-1));
Y=freqz(y(1000:2023),1,W);
Y=Y./max(abs(Y));
figure(3);subplot(212);plot(W/pi,abs(Y));grid on;
xlabel('Hz');ylabel('dB');
title('I/Q Downconverted Signal');
axis([-1 1 0 1.1]);
figure;
hold on;
plot(y(1+over:over:end),'*','MarkerSize',8);hold on;
ph=(0:5:360)*pi/180; plot(3*1.414*cos(ph),3*1.414*sin(ph),'c');
hold on;
plot([-4 4], [0 0], 'k:',[0 0], [-4 4], 'k:');
hold off; axis equal;
axis([-6 6 -6 6]);grid;
xlabel('Re[16qam]');ylabel('Im[16qam]');
title('16-QAM Constellation-Complex');
hold off;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -