📄 rayleigh_fading_waveform.m
字号:
clear all;
close all;
%% set parameter
fs = 32*(10^6);
Ts = 1/fs;
fm = 500;
N = 128;
N0 = N/4;
n = 1:N0;
path_number = 6;
sample_number = 2000;
alpha = 2*pi*n/N-pi/N;
beta = pi*n/N0;
theta = 2*pi.*rand(N0,path_number);
%% generate Walsh-Hadamard codeword
A = hadamard(N0);
%% generate rayleigh fading waveform
run = 50;
p = [-3 0 -2 -6 -8 -10];
pp = (10.^(p./20)).^2;
pp = sqrt(pp/sum(pp));
temp1 = cos(beta) + j*sin(beta);
for ii = 1:path_number
temp2 = A(ii,:);
temp = temp1.*temp2*sqrt(2/N0)*pp(ii);
theta = repmat(theta(:,ii),1,(sample_number/run));
for i = 1:run
t(i,:) = ((i-1)*(sample_number/run))*Ts :Ts: (i*sample_number/run-1)*Ts;
temp3 = cos(2*pi*fm*(cos(alpha'))*t(i,:) + theta);
gamma = temp*temp3;
switch ii
case 1
fid1 = fopen('gamma_path1_real.txt','a+');
fprintf(fid1,'%f ',real(gamma));
fclose(fid1);
fid2 = fopen('gamma_path1_imaginary.txt','a+');
fprintf(fid2,'%f ',imag(gamma));
fclose(fid2);
case 2
fid1 = fopen('gamma_path2_real.txt','a+');
fprintf(fid1,'%f ',real(gamma));
fclose(fid1);
fid2 = fopen('gamma_path2_imaginary.txt','a+');
fprintf(fid2,'%f ',imag(gamma));
fclose(fid2);
case 3
fid1 = fopen('gamma_path3_real.txt','a+');
fprintf(fid1,'%f ',real(gamma));
fclose(fid1);
fid2 = fopen('gamma_path3_imaginary.txt','a+');
fprintf(fid2,'%f ',imag(gamma));
fclose(fid2);
case 4
fid1 = fopen('gamma_path4_real.txt','a+');
fprintf(fid1,'%f ',real(gamma));
fclose(fid1);
fid2 = fopen('gamma_path4_imaginary.txt','a+');
fprintf(fid2,'%f ',imag(gamma));
fclose(fid2);
case 5
fid1 = fopen('gamma_path5_real.txt','a+');
fprintf(fid1,'%f ',real(gamma));
fclose(fid1);
fid2 = fopen('gamma_path5_imaginary.txt','a+');
fprintf(fid2,'%f ',imag(gamma));
fclose(fid2);
case 6
fid1 = fopen('gamma_path6_real.txt','a+');
fprintf(fid1,'%f ',real(gamma));
fclose(fid1);
fid2 = fopen('gamma_path6_imaginary.txt','a+');
fprintf(fid2,'%f ',imag(gamma));
fclose(fid2);
end
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -