声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1588|回复: 0

[综合讨论] 求助matlab的QPSK解调代码 有调制的代码

[复制链接]
发表于 2010-3-26 13:52 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
这个程序写得很好的,可是解调怎么写?
%file name: qpsk.m
%Written by Dr. James S. Kang, Cal Poly Pomona.
%Plot of QPSK waveform and spectrum.
%d = input data such as [1 1 0 0 1 0 0 1 1 1].
%fb = data rate in bps.
%fc = carrier frequency.
%Ac = Amplitude of the carrier.
%fstart = start frequency for spectrum plot.
%fend = end frequency for spectrum plot.
%To run the program, try
% >>qpsk([1 1 0 0 1 0 1 0 1 1],500,1000,1,0,4000)  <Enter>
function = qpsk(d,fb,fc,Ac,fstart,fend);
N=size(d,2);        %N = number of data bits.
if rem(N,2) == 1
        N=N+1
        d(N)=0
end
N2=N/2;
M=32;        %M = number of samples per bit duration.
tb=1/fb;tc=1/fc;
Nc=floor(M*tc/tb); %Nc = number of samples per period of carrier.
step=tb/M;        %step = sampling interval.
for j = 1:N
        if d(j) == 1
           for i = 1:M
                m((j-1)*M+i)=1;
           end
        else
           for i = 1:M
                m((j-1)*M+i)=-1;
           end
        end
end
for j = 1:N2
        if d(j*2-1) == 1
           for i = 1:2*M
                mi((j-1)*2*M+i)=1;
                si((j-1)*2*M+i)=Ac*cos(2*pi*(i-1)/Nc);
           end
        else
           for i = 1:2*M
                mi((j-1)*2*M+i)=-1;
                si((j-1)*2*M+i)=Ac*cos(2*pi*(i-1)/Nc+pi);
           end
        end
        if d(j*2) == 1
           for i = 1:2*M
                mq((j-1)*2*M+i)=1;
                sq((j-1)*2*M+i)=Ac*sin(2*pi*(i-1)/Nc);
           end
        else
           for i = 1:2*M
                mq((j-1)*2*M+i)=-1;
                sq((j-1)*2*M+i)=Ac*sin(2*pi*(i-1)/Nc+pi);
           end
        end
end
for k=1:M*N
        t(k)=(k-1)*step;
        s(k)=si(k)+sq(k);
end
figure
subplot(3,1,1)
plot(t,m)
grid
%xlabel('Time')
ylabel('Amplitude')
title('Input Waveform')
subplot(3,1,2)
plot(t,mi)
grid
%xlabel('Time')
ylabel('Amplitude')
title('I Channel Waveform')
subplot(3,1,3)
plot(t,mq)
grid
xlabel('Time')
ylabel('Amplitude')
title('Q Channel Waveform')
figure
subplot(3,1,1)
plot(t,si)
grid
%xlabel('Time')
ylabel('Amplitude')
title('I Channel Modulated Waveform')
subplot(3,1,2)
plot(t,sq)
grid
%xlabel('Time')
ylabel('Amplitude')
title('Q Channel Modulated Waveform')
subplot(3,1,3)
plot(t,s)
grid
xlabel('Time')
ylabel('Amplitude')
title('QPSK Waveform')
%
%Spectrum of QPSK
%
M1=64;        %M1 = number of points per lobe.
fstep=fb/M1; %fstep = freq. step.  
Nf=floor((fend-fstart)/fstep); %Nf = total number of freq. points computed.
for i = 1:Nf
f(i)=(i-1)*fstep+fstart;
        if f(i) == fc S(i)=Ac^2*tb;
        else
         S(i)=(Ac^2*tb)*(sin(pi*(f(i)-fc)*2*tb)/(pi*(f(i)-fc)*2*tb))^2;
        end
end
for i = 1:Nf
dBS(i) = 10*log(S(i));
if dBS(i) < -200 dBS(i)=-200; end
end
figure
subplot(2,1,1)
plot(f,S)
grid
%xlabel('Frequency')
ylabel('Magnitude')
title('QPSK Spectrum (Linear)')
subplot(2,1,2)
plot(f,dBS)
grid
xlabel('Frequency')
ylabel('Magnitude')
title('QPSK Spectrum (dB)')
end
回复
分享到:

使用道具 举报

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-14 14:48 , Processed in 0.053321 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表