📄 qam.m
字号:
function [y,fs,fb,fc]=qam(x,Kbase,fs,fb,fc);
%
% Usage:[y,fs,fb,fc]=qam(x,Kbase,fs,fb,fc);BBI;Kbase=1表示不采用基带形成,Kbase=2表示采用
% 基带成形
if nargin<5;fc=2; end;
if nargin<4;fb=1; end;
if nargin<3;fs=32; end;
if nargin<2;Kbase=2;end;
if nargin<1;
x=[1 1 1 1 1 1 1 0 1 1 0 1 1 1 0 0];
x=[x 1 0 1 1 1 0 1 0 1 0 0 1 1 0 0 0];
x=[x 0 0 1 1 0 0 1 0 0 0 0 1 0 0 0 0];
x=[x 0 1 1 1 0 1 1 0 0 1 0 1 0 1 0 0];
end;
T=length(x)/fb;m=fs/fb;nn=length(x);
dt=1/fs;t=0:dt:T-dt;
Kbase=rem(Kbase,2);Kbase=Kbase+(Kbase==0)*2;tstr='QAM';
I=x(1:2:nn-1); [I,In]=two2four(I,4*m);
Q=x(2:2:nn); [Q,Qn]=two2four(Q,4*m);
if Kbase==2;
I=bshape(I,fs,fb/4);Q=bshape(Q,fs,fb/4);
end;
y=I.*cos(2*pi*fc*t)-Q.*sin(2*pi*fc*t);y1=y;
n=length(y);
%-------------------------------------------------
if nargout<1;
subplot(211);
plot(t,y,t,I,t,Q,[0 T],[0 0],'b:');
if Kbase==2;
tstr=[tstr 'with the RC filter'];
end;title('Signal');
n=length(y);y=fft(y)/n;y=abs(y(1:fix(n/2)))*2;
I=find(y<1e-04);y(I)=1e-04;y=20*log10(y);
f1=m/n;f=0:f1:(length(y)-1)*f1;
subplot(223);plot(f,y,'r');grid on;
title('Spectrum');xlabel('f/fb');zoom xon;
subplot(224);constel(y1,fs,fb,fc);xlabel('Constelltion');
set(gcf,'num','off','name',['tstr','blanks(10)','BBI 2000']);
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -