【正文】
R=R*ts。NOISE=NOISE*ts。n_cutoff=floor(70/df1)。H(1:n_cutoff)=2*ones(1,n_cutoff)。yy=r.*c。YY=YY*ts。%濾波dem=real(ifft(DEM))/fs。ytemp=dem。for i=(1:length(t))。 y1(1,i)=1。 end。for i=(1:10)。 if mean(k)。 else y2(i)=0。for i=(2:10)。endfor i=(1:10)。 l=(i1)*15+j。 yout(l)=1。 end end end [Y1,y1,df1]=fftseq(y1,ts,df)。[YOUT,yout,df1]=fftseq(yout,ts,df)。pause。figure(1)。plot(t,mi(1:length(t)))。axis([0 2 2])。Time39。title(39。)。plot(f,abs(fftshift(M)))。Frequency39。 title(39。)。plot(t,bn1(1:length(t)))。axis([0 2 2])。Time39。title(39。)。plot(f,abs(fftshift(BN1)))。Frequency39。title(39。)。plot(t,c(1:length(t)))。axis([0 2 2])。Time39。title(39。)。plot(f,abs(fftshift(C)))。Frequency39。title(39。)。figure(2)。plot(t,noise(1:length(t)))。axis([0 2 2])。Time39。title(39。)。plot(f,abs(fftshift(NOISE)))。Frequency39。title(39。)。plot(t,y(1:length(t)))。axis([0 2 2])。Time39。title(39。)。plot(f,abs(fftshift(Y)))。Frequency39。 title(39。)。plot(t,r(1:length(t)))。axis([0 2 2])。Time39。title(39。)。plot(f,abs(fftshift(R)))。Frequency39。 title(39。)。figure(3)。plot(t,yy(1:length(t)))。axis([0 2 2])。Time39。title(39。)。plot(f,abs(fftshift(YY)))。Frequency39。 title(39。)。plot(t,dem(1:length(t)))。xlabel(39。)。低通后波形39。subplot(3,2,4)。xlabel(39。)。低通后頻譜39。subplot(3,2,5)。grid。xlabel(39。)。抽樣判決后波形39。subplot(3,2,6)。xlabel(39。)。抽樣判決后頻譜39。pause。subplot(2,2,1)。grid。xlabel(39。)。碼反變換后波形39。subplot(2,2,2)。xlabel(39。)。碼反變換后頻譜39。subplot(2,2,3)。grid。xlabel(39。)。源信號(hào)波形39。subplot(2,2,4)。xlabel(39。)。源信號(hào)頻譜39。16QAM調(diào)制解調(diào)程序clear。ts=。snr=10。df=。snr_lin=10^(snr/10)。for i=1:10 x=rand。 c(l)=cos(2*pi*fc*t(l))。 if x= mi(l)=3。 elseif x= mi(l)=1。 end endendfor i=1:10 x=rand。 c(l)=cos(2*pi*fc*t(l))。 if x= mq(l)=3。 elseif x= mq(l)=1。 end endendnm=length(t)。mq(nm)=mq(nm1)。ask2=mq.*s。%加噪聲signal_power=spower(y(1:length(t)))。 % pute noise powernoise_std=sqrt(noise_power)。 % generate noiser=y+noise。yq=r.*s。mk=mi。[M1,mk,df1]=fftseq(mk,ts,df)。[M2,ml,df1]=fftseq(ml,ts,df)。[C,c,df1]=fftseq(c,ts,df)。[S,s,df1]=fftseq(s,ts,df)。[ASK1,ask1,df1]=fftseq(ask1,ts,df)。[ASK2,ask2,df1]=fftseq(ask2,ts,df)。f=[0:df1:df1*(length(mk)1)]fs/2。NOISE=NOISE*ts。[U,u,df1]=fftseq(u,ts,df)。[R,r,df1]=fftseq(r,ts,df)。[Yi,yi,df1]=fftseq(yi,ts,df)。[Yq,yq,df1]=fftseq(yq,ts,df)。%濾波f_cutoff=70。H=zeros(size(f))。H(length(f)n_cutoff+1:length(f))=2*ones(1,n_cutoff)。dem1=real(ifft(DEM1))/fs。dem2=real(ifft(DEM2))/fs。dem2=dem2(1:length(t))。 k=dem1((i1)*15+1:i*15)。 for j=(1:15) l=(i1)*15+j。 k=dem2((i1)*15+1:i*15)。 for j=(1:15) l=(i1)*15+j。Y1=Y1/fs。Y2=Y2/fs。figure(1)subplot(2,2,1)plot(t,mi(1:length(t)))。axis([0 ])。Time39。title(39。)。xlabel(39。)。源信號(hào)1頻譜39。subplot(2,2,3)plot(t,mq(1:length(t)))。axis([0 ])。Time39。title(39。)。xlabel(39。)。源信號(hào)2頻譜39。pause。grid。xlabel(39。)。載波1波形39。subplot(2,2,2)plot(f,abs(fftshift(C)))。Frequncy39。title(39。)。grid。xlabel(39。)。載波2波形39。subplot(2,2,4)plot(f,abs(fftshift(S)))。Frequncy39。title(39。)。figure(3)subplot(2,2,1)plot(t,ask1(1:length(t)))。axis([0 5 5])。Time39。title(39。)。xlabel(39。)。4ASK信號(hào)1頻譜39。subplot(2,2,3)plot(t,ask2(1:length(t)))。axis([0 5 5])。Time39。title(39。)。xlabel(39。)。4ASK信號(hào)2頻譜39。pause。grid。xlabel(39。)。噪聲波形39。subplot(3,2,2)plot(f,abs(fftshift(NOISE)))。Frequency39。title(39。)。grid。xlabel(39。)。未加噪聲調(diào)制16QAM波形39。subplot(3,2,4)plot(f,abs(fftshift(U)))。Frequncy39。title(39。)。grid。xlabel(39。)。加噪聲調(diào)制16QAM波形39。subplot(3,2,6)plot(f,abs(fftshift(R)))。Frequncy39。title(39。)。figure(5)subplot(2,2,1)plot(t,yi(1:length(t)))。xlabel(39。)。相干解調(diào)后信號(hào)1波形39。subplot(2,2,2)plot(f,abs(fftshift(Yi)))。Frequncy39。title(39。)。grid。Time39。title(39。)。xlabel(39。)。低通后信號(hào)1頻譜39。pause。grid。Time39。title(39。)。xlabel(39。)。相干解調(diào)后信號(hào)2頻譜39。subplot(2,2,3)plot(t,dem2(1:length(t)))。xlabel(39。)。低通后信號(hào)2波形39。subplot(2,2,4)plot(f,abs(fftshift(DEM2)))。Frequency39。title(39。)。figure(7)subplot(2,2,1)plot(t,y1(1:length(t)))。axis([0 ])。Time39。title(39。)。xlabel(39。)。抽樣判決后信號(hào)1頻譜39。subplot(2,2,3)plot(t,mi(1:length(t)))。axis([0 ])。Time39。title(39。)。xlabel(39。)。源信號(hào)1頻譜39。pause。grid。xlabel(39。)。抽樣判決后信號(hào)2波形39。subplot(2,2,2)plot(f,abs(fftshift(Y2)))。Frequency39。title(39。)subplot(2,2,3)plot(t,mq(1:length(t)))。axis([0 ])。Time39。title(39。)。xlabel(39。)。源信號(hào)2頻譜39。function [M,m,df]=fftseq(m,ts,df) % [M,m,df]=fftseq(m,ts,df)% [M,m,df]=fftseq(m,ts)%FFTSEQ generates M, the FFT of the sequence m.% The sequence is zero padded to meet the required frequency resolution df.% ts is the sampling interval. The output df is the final frequency resolution.% Output m is the zero padded version of input m. M is the FFT.fs=1/ts。else n1=fs/df。n=2^(max(nextpow2(n1),nextpow2(n2)))。m=[m,zeros(1,nn2)]。function p=spower(x)% p=spower(x)%SPOWER returns the power in signal xp=(norm(x)^2)/length(x)