📄 mimo_channel.m
字号:
function Channel_H = mimo_channel(Tx_n, Rx_n, Path_n, fc, v, fs, time_slot, Channel_n)
% 衰落信道程序(jakes)
% usage: ch = mimo_channel(1, 1, 2, 900, 150, 250000, 2000,1)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Tx_n : the Tx antenna number
% Rx_n : the Rx antenna number
% Path_n : multipath except the main path
% fc: the carrier frequency.( MHz )
% v: the speed of vehicle.( Km/h )
% fs: the sample frequency.(Hz)
% time_slot: the time duration
% Channel_n : the realization number of channel
% must agree that time_slot*fmax>=Q; if Q=0, and Path_n=0 then it is the flat fading.
% if Path_n=0, then it is the time-selective channel
% if Q=0, then it is the frequency-selective channel
i = sqrt(-1);
c=3e8;
%******* for debug ******
% Tx_n=1;
% Rx_n=1;
% Path_n=2;
% fc=900;
% v=50;
% fs=10000;
% time_slot=500;
% Channel_n=1;
%****** for debug *******
fmax=fc*v/c*1e6*1e3/3600;
Power_profile = sqrt(exp(-[0:Path_n]/2));
Power_profile=Power_profile/norm(Power_profile);
if fmax > 0
file = sprintf('MIMO_T%dR%dFc%dP%dV%dFs%dN%dC%d',Tx_n, Rx_n, fc, Path_n, v, fs, time_slot, Channel_n);
N = 8;
while(N)
if (N < 2*fmax*time_slot/fs)
N = 2*N;
else
break;
end
end
% N = 20;
% N
fd = cos(2*pi*((1:N)/N))*fmax; % Generating uniformly spaced
for realization = 1:Channel_n
for tx = 1 : Tx_n
for rx = 1 : Rx_n
for path = 1 : Path_n+1
rand('state',sum(100*clock));
theta = rand(1,N)*2*pi; % Generating the uniform phases
%theta = ([1:N]-1)/N*2*pi;
% frequencies from -fdmax to +fdmax
for t = 1:time_slot
real_time = t/fs;
one_tv_link(t) = sum((exp(i*(2*pi*fd*real_time + theta))));
end
Channel_H(rx, tx, path, :, realization) = one_tv_link * Power_profile(path)/sqrt(N);
% add up the value of all path for different time_slot point
% result = result+one_tv_link*Power_profile(path)/sqrt(N);
end
end
end
if(mod(realization,50) == 0)
fprintf(1, '.');
end
if(mod(realization,2000) == 0)
fprintf(1,'\n');
end
end
elseif fmax == 0
% generate frequency-selective channel or flat fading channel
file = sprintf('MIMO_flat_T%dR%dFc%dP%dD%dN%dC%d',Tx_n, Rx_n, fc, Path_n, fmax, time_slot, Channel_n);
for realization = 1:Channel_n
for tx = 1 : Tx_n
for rx = 1 : Rx_n
for path = 1 : Path_n+1
one_tv_link = (randn(1,1)+j*randn(1,1))/sqrt(2).*ones(1,time_slot)*Power_profile(path);
Channel_H(rx, tx, path, :, realization) = one_tv_link;
end
end
end
if(mod(realization,50) == 0)
fprintf(1, '.');
end
if(mod(realization,2000) == 0)
fprintf(1,'\n');
end
end
else
fprintf(1,'error Dopplor');
end
tv_link= Channel_H(1,1,1,:,1);
tv_link=tv_link(:);
% plot(real(tv_link),'r-');
% hold on
% plot(imag(tv_link),'b:');
% title(['fc= ' num2str(fc) 'MHz V= ' num2str(v)]);
% figure
% plot(10*log10(abs(tv_link)));
% title(['fc= ' num2str(fc) 'MHz V= ' num2str(v) 'Km/h Ts= ' num2str(1/fs*1e6) 'us']);
% hist(abs(tv_link),20);
%mean(10*log10(abs(tv_link).^2))
% save(file, 'Channel_H', 'Tx_n', 'Rx_n' ,'Path_n', 'fc' ,'v' ,'fs', 'time_slot');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -