2ASK调制解调系统MATLAB源程序 下载本文

2ASK调制解调系统MATLAB源程序 %产生数字基带信号

figure('Name','数字信号调制过程中波形及其频谱','NumberTitle','off') fc=1000;

fs=4000; ts=1/fs; snr=10;v=100; N=40;m=40; bit=randint(1,m); bits=[];sig=[];

for i=1:length(bit) %%length(m)表示信号m的长度 if bit(i)==0 bits=zeros(1,N); else

bits=ones(1,N); end

sig=[sig,bits]; end

[Pxx,Pxxc,f] = pmtm(sig,3.5,1024,fs,0.99); SIG= dspdata.psd(Pxx,'Fs',fs); t=ts:ts:ts*m*N;

s=cos(2*pi*fc*t); %载波信号

[Pxx,Pxxc,f] = pmtm(s,3.5,1024,fs,0.99); S= dspdata.psd(Pxx,'Fs',fs); s_ask=sig.*s; %调制信号

[Pxx,Pxxc,f] = pmtm(s_ask,3.5,1024,fs,0.99); S_ASK = dspdata.psd(Pxx,'Fs',fs);

subplot(321);plot(sig);title('数字基带信号');axis([0 800 -0.5 1.5]);grid on; subplot(322);plot(SIG);title('数字基带信号功率谱');

subplot(325);plot(t,s);title('载波信号波形');axis([0 0.4 -1.5 1.5]); subplot(326);plot(S);title('载波信号功率谱');

subplot(323);plot(t,s_ask);title('调制后信号波形');axis([0 0.4 -1.5 1.5]); subplot(324);plot(S_ASK);title('调制后信号功率谱');

%添加噪声

figure('Name','噪声及带通滤波','NumberTitle','off') y = awgn(s_ask,snr);

[Pxx,Pxxc,f] = pmtm(y,3.5,1024,fs,0.99); Y = dspdata.psd(Pxx,'Fs',fs); a=[700,1300];

Wp=a/(fs/2);Rp=0.1; Rs=35; Rp=0.1;Rs=35;

[b,a]=ellip(4,Rp,Rs,Wp); q=filter(b,a,y);

[Pxx,Pxxc,f] = pmtm(q,3.5,1024,fs,0.99); Q= dspdata.psd(Pxx,'Fs',fs);

subplot(221);plot(t,y);title('添加噪声后信号波形') subplot(222);plot(Y);title('添加噪声后信号') subplot(223);plot(t,q);title('带通滤波信号')

subplot(224);plot(Q);title('带通滤波信号')

%低通滤波及抽样判决

figure('Name','低通滤波及抽样判决','NumberTitle','off') ask=q.*s;

Wp=300/(fs/2);%Ws=110/(fs/2); Rp=0.1; Rs=35;

[b,a]=ellip(4,Rp,Rs,Wp); ss_ask=filter(b,a,ask);

[Pxx,Pxxc,f] = pmtm(ss_ask,3.5,1024,fs,0.99); SS_ASK= dspdata.psd(Pxx,'Fs',fs);

subplot(221);plot(t,ss_ask);title('低通滤波信号') subplot(222);plot(SS_ASK);title('低通滤波信号功率谱') sss=[]; for i=1:m

if ss_ask(N*(i-1)+N/2)>0.5 bits=ones(1,N); else

bits=zeros(1,N); end

sss=[sss,bits]; end

subplot(223);plot(sss);title('抽样判决信号');axis([0 850 -0.5 1.5]);grid on;