📄 qpsk.m
字号:
function [y,Kmod,fs,fb,fc]=qpsk(x,Kmod,Kbase,fs,fb,fc);
%
% Usage:[y,Kmod,fs,fb,fc]=qpsk(x,Kmod,Kbase,fs,fb,fc);BBI
% 2000;Kmod=1表示QPSK调制,=2表示QDPSK调制,其中用到的qdpskcd.m完成QDPSK的码变换,还有constel.m用来完成
% 绘制星座图
if nargin<6; fc=2; end;
if nargin<5; fb=1;end;
if nargin<4;fs=32; end;
if nargin<3;Kbase=2; end;
if nargin<2; Kmod=1; end;%Kmod=1,QPSK;Kmod=2,QDPSK;
if nargin<1;x=[0 0 0 1 1 1 1 0];end;
T=length(x)/fb;m=fs/fb;nn=length(x);
dt=1/fs;t=0:dt:T-dt;
Kmod=rem(Kmod,2); Kmod=Kmod+(Kmod==0)*2;
Kbase=rem(Kbase,2);Kbase=Kbase+(Kbase==0)*2;
if Kmod==1;
x1=x*2-1;tstr='QPSK';
elseif Kmod==2;
x1=dqpskcd(x);x1=x1*2-1;tstr=['QDPSK'];
end;
I=x1(1:2:nn-1);Q=x1(2:2:nn);
I=pulse(I,2*m);Q=pulse(Q,2*m);
if Kbase==2;
I=bshape(I,fs,fb/2);Q=bshape(Q,fs,fb/2);
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;axis([0,15,-80,0]);
title('Specturm');xlabel('f/fb');zoom xon;
subplot(224);constel(y1,fs,fb,fc);xlabel('Constellation');
set(gcf,'num','off','name',['tstr','blanks(10),''BBI 2000']);
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -