www.gusucode.com > MC-CDMA系统的仿真matlab源码程序 > mc-cdma/rayleigh(移动信道)/Rayleigh.m
function fading=Rayleigh(fd) t0=0; Wm=2*pi*fd; fs=4e6/256; %Some parameters. N0=8; N=2*(2*N0+1); % N=4*(N0+1); %Resetting of the in-phase and Q-phase channel response. pNum =6; % pNum =4; Len =10000; Xi=zeros(pNum,Len); Xq=zeros(pNum,Len); for ii=1:pNum % Set beta and sita. beta=zeros(1,N0); sita=zeros(1,N0); for i1=1:N0 beta(1,i1)=pi*i1/(N0+1); sita(1,i1)=beta(1,i1)+2*pi*(ii-1)/(N0+1); end for i1=0:Len-1 % Calculate cosine for different i2. csin=zeros(1,N0); for i2=1:N0 csin(1,i2)=cos(Wm*cos(2*pi*i2/N)*(i1/fs+t0)+sita(1,i2)); end % Channel response. Xi(ii,i1+1)=2*cos(beta)*csin'+1.414*cos(Wm*(i1/fs+t0)); Xq(ii,i1+1)=2*sin(beta)*csin'; end end CH=1.414/N^0.5*(Xi+j*Xq); for ii=1:pNum CH(ii,:) = sqrt(size(CH,2))*CH(ii,:)/norm(CH(ii,:)); end %Mean amplitude values for different paths in decimal format: PDF=[0 -1.0 -9.0 -10.0 -15.0 -20.0]'; % in dB MeanPower = 10.^(PDF/10); MeanAmp = sqrt( MeanPower/sum(MeanPower)/2); %Nomorlized the power to 1. MeanAmp=repmat(MeanAmp,1,Len); % MeanAmp=[1 0.7305 0.3175 0.1137]'; % MeanAmp=repmat(MeanAmp,1,Len); fading=MeanAmp.*CH; % plot(1/fs*[1:Len],abs(fading))