ip_07_09.m
上传用户:m_sun_001
上传日期:2014-07-30
资源大小:1115k
文件大小:1k
- % MATLAB script for Illustrative Problem 9, Chapter 7.
- % echo on
- clear;
- K=10; N=2*K; Ts=25; T=N*Ts;
- a=rand(1,(K-1)*4); % k-1符号,1个保护间隔0
- a=sign(a-0.5);
- b=reshape(a,K-1,4);
- % Generate the 16QAM points
- XXX=2*b(:,1)+b(:,2)+j*(2*b(:,3)+b(:,4)); % 随机声称9个16点QAM星座点
- XX=XXX';
- X=[0 XX 0 conj(XX(K-1:-1:1))]; % X长度为20,等于N
- xt=zeros(1,T+1);
- % IDFT t
- for t=0:T % 载波分辨力
- for k=0:N-1 % 载波数量
- xt(t+1)=xt(t+1)+1/sqrt(N)*X(k+1)*exp(j*2*pi*k*t/T);
- end
- end
- % IDFT n
- xn=zeros(1,N);
- for n=0:N-1
- for k=0:N-1
- xn(n+1)=xn(n+1)+1/sqrt(N)*X(k+1)*exp(j*2*pi*n*k/N);
- end
- end
- % IFFT
- xn1=ifft(X,N)*sqrt(N);
- % pause % press any key to see a plot of x(t)
- plot([0:T],real(xt),'r',[0:T/N:T-T/N],xn,'.b',[0:T/N:T-T/N],xn1,'og'),grid
- legend('连续信号','采样信号','IFFT信号*4.5')
- hold on % 画出每个子载波波形
- for ii=[10,12]
- plot([0:T],1/sqrt(N)*X(ii)*exp(j*2*pi*(ii-1)*[0:T]/T),':')
- end
- hold off
- % Check the difference between xn and samples of x(t)
- for n=0:N-1
- d(n+1)=xt(T/N*n+1)-xn(1+n);
- % echo off
- end
- % echo on
- e=norm(d);
- Y=zeros(1,K);
- % DFT
- for k=0:K-1
- for n=0:N-1
- Y(k+1)=Y(k+1)+1/sqrt(N)*xn(n+1)*exp(-j*2*pi*k*n/N);
- end
- end
- Y1=fft(xn1,N)/sqrt(N);
- % echo on
- dd=Y(1:K)-X(1:K);
- dd1=Y1(1:K)-X(1:K);
- ee=norm(dd)
- ee2=norm(dd1)