%函数Rayleigh_filtered
%Ns表示抽样得到的瑞利衰落信道点数
function rayleigh_t=Rayleigh_filtered(fmax,fs,Ns)
%N为仿真中瑞利衰落信道的实际点数,它的确定需要考虑数字信号处理的内容
N=8;
while(N)
if (N<2*fmax*Ns/fs)
N=2*N;
else
break;
end
end
%N_inv为IFFT实际点数
N_inv=ceil(N*fs/(2*fmax));
%f_interval为信号FFT之后的频率间隔
f_interval=2*fmax/N;
%T_inv为抽样点之间的间隔
T_inv=1/fs;
%产生具有N点的高斯随机变量
I_input_time=randn(1,N);
Q_input_time=randn(1,N);
%做FFT变换
I_input_freq=fft(I_input_time);
Q_input_freq=fft(Q_input_time);
%产生具有经典功率谱的成形滤波器
SEZ(1)=1.5/(pi*fmax);
%****0<f<fmax*****
for j=2:N/2
f(j)=(j-1)*f_interval;
SEZ(j)=1.5/(pi*fmax*sqrt(1-(f(j)/fmax)^2));
SEZ(N-j+2)=SEZ(j);
end
%f=fmax点的值采用多项式拟合的方法求得
k=3;
p=polyfit(f(N/2-k:N/2),SEZ(N/2-k:N/2),k);
SEZ(N/2+1)=polyval(p,f(N/2)+f_interval);
%高斯随机变量通过成形滤波器
I_output_freq=I_input_freq.*sqrt(SEZ);
Q_output_freq=Q_input_freq.*sqrt(SEZ);
%做IFFT变换
I_temp=[I_output_freq(1:N/2) zeros(1,N_inv-N) I_output_freq(N/2+1:N)];
I_output_time=ifft(I_temp);
Q_temp=[Q_output_freq(1:N/2) zeros(1,N_inv-N) Q_output_freq(N/2+1:N)];
Q_output_time=ifft(Q_temp);
%得到衰落信道的冲激响应CHANNEL
channel=I_output_time+i*Q_output_time;
channel=channel(1:Ns);
%用均方根(RMS)进行归一化
rms=sqrt(norm(channel,'fro'));
channel_unit=channel/rms;
rayleigh_t=diag(channel_unit'*channel_unit)';
评论0