qpsk.m

来自「qpskmod.rar」· M 代码 · 共 38 行

M
38
字号
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
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';
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;
    title('Spectrum'); xlabel('f/fb');zoom xon;
    subplot(224);  constel (y1,fs,fb,fc);xlabel('Constellation');
    set(gcf,'num','off','name',[tstr','blanks(10)'BBI2000']);
end;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?