📄 example_mimo.asv
字号:
clear all;
close all;
% User-defined parameters %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Direction of connection
Connection = 'downlink';
% Distance Tx-Rx
Distance_Tx_Rx_m = 3;
% Carrier frequency
CarrierFrequency_Hz = 5.25e9;
% Power line frequency
PowerLineFrequency_Hz = 50; %? lid
% Antenna configuration at Tx
NumberOfTxAntennas = 2;
Spacing_Tx = 1;
% Antenna configuration at Rx
NumberOfRxAntennas = 2;
Spacing_Rx = .5;
% IEEE 802.11 case to be simulated
IEEE_802_11_Case = 'E';
% Complex field or real power correlation coefficients?
CorrelationCoefficientType = 'complex';
% Simulation length, in coherence times
SimulationLengthInCoherenceTimes = 100;
% NumberOfIterations of the vector of fading coefficients
FadingNumberOfIterations = 512;%? lid
% Sampling rate
SamplingRate_Hz = 125000;
% Factor defining the lower rate at which channel samples are collected
DownSamplingFactor = 48;
% Seed of Random Generator
RandomSeed = 0;
% Revision history
%
% February 2004 - Bug fixes
% o AoA/AoD at mobile hard-coded to 45 degrees
% Thanks to Steven Howard and Irina Medvedev, Qualcomm
% (USA) for reporting the bug.
% o Aliasing of the fluorescent effect due to a too low
% FadingSamplingFrequency_Hz. Channel response now
% interpolated in two steps, before and after
% the addition of the fluorescent effect, such that
% the highest harmonic of this effect falls within
% the Nyquist frequency of the fading. Thanks to
% Stefano Valle and Angelo Poloni, STMicroelectronics
% Srl, Italy for fixing this bug.
% January 2004 - Introduced PDP normalisation following a suggestion
% by Hemanth Sampath, Marvell. Fixed LOS component
% addition, with help of Steve Howard, Qualcomm.
% Improved initialisation of filter states to cancel
% transients; implementation by Stefano Valle and
% Angelo Poloni, STMicroelectronics Srl, Italy
% ( Bas Dijkstra and Laurent Schumacher )
% December 2003 - Fixed three brugs reported by Stefano Valle and
% Angelo Poloni, STMicroelectronics Srl, Italy
% ( Bas Dijkstra and Laurent Schumacher )
% November 2003 - Updated to rely on time-domain fading generation
% in compliance with IEEE 802.11-03/940r1
% Filters designed by Stefano Valle and
% Angelo Poloni, STMicroelectronics Srl, Italy
% ( Bas Dijkstra and Laurent Schumacher )
% October 2003 - Updated in compliance with IEEE 802.11-03/161r2
% ( Bas Dijkstra )
% February 2002 - Creation
% ( Laurent Schumacher )
%
%
% STANDARD DISCLAIMER
%
% The Computer Science Institute of the University of Namur (hereafter
% "FUNDP-INFO") is furnishing this item "as is". FUNDP-INFO does not
% provide any warranty of the item whatsoever, whether express,
% implied, or statutory, including, but not limited to, any warranty
% of merchantability or fitness for a particular purpose or any
% warranty that the contents of the item will be error-free.
%
% In no respect shall FUNDP-INFO incur any liability for any damages,
% including, but not limited to, direct, indirect, special, or
% consequential damages arising out of, resulting from, or any way
% connected to the use of the item, whether or not based upon
% warranty, contract, tort, or otherwise; whether or not injury was
% sustained by persons or property or otherwise; and whether or not
% loss was sustained from, or arose out of, the results of, the
% item, or any services that may be provided by FUNDP-INFO.
%
% (c) Laurent Schumacher, FUNDP-INFO - January 2004
% Hard-coded parameters %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% According to IEEE 802.11-03/0940r1
% Speed of movement of scattering environment (p. 17)
v0_kmh = 1.2;
% Speed of car passing by (p. 18)
v1_kmh = 40;
% Fluorescent effect - Mean of the Gaussian random variable (p. 29)
GaussianMean = 0.0203;
% Fluorescent effect - Standard deviation of the Gaussian random variable (p. 29)
GaussianStandardDeviation = 0.0107;
% Filter design - Not to be changed unless the filters hard coded in init_fading_time.m
% will not fit any more
% Filter order
Filter_Order = 7;
% Normalised Doppler spread f_D
f_D_norm = 1/300;
% Initialisation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Random generator
if (RandomSeed ~= 0)
randn('state',RandomSeed);
else
randn('state',sum(100*clock));
end;
RandState = randn('state');
% Parameters' conversion
Wavelength_m = 3e8/CarrierFrequency_Hz;
% SpeedOfMovement_ms = SpeedOfMovement_kmh/3.6;
v0_ms = v0_kmh/3.6;
v1_ms = v1_kmh/3.6;
% Cut-off frequency f_D, in Hz
f_D_Hz = v0_ms/Wavelength_m;
% Spike frequency, in Hz
f_spike_Hz = v1_ms/Wavelength_m;
% Definition of time scales
SamplingTime_s = 1/SamplingRate_Hz;
% Fading sampling
FadingSamplingFrequency_Hz = f_D_Hz/f_D_norm;
FadingSamplingTime_s = 1/FadingSamplingFrequency_Hz;
% Check for aliasing of the fluorescent effect
% Highest harmonic = 10*PowerLineFrequency_Hz
% Nyquist frequency of the first interpolation = 1/2 *(10*FadingSamplingFrequency_Hz)
if ((10*PowerLineFrequency_Hz)>(5*FadingSamplingFrequency_Hz))
disp('Warning! Aliasing of the fluorescent effect!');
disp('Highest harmonic falls beyond Nyquist frequency of the fading samples!');
end;
% Oversampling factor
OversamplingFactor = SamplingRate_Hz/FadingSamplingFrequency_Hz;
% Derivation of the PDP and the correlation matrices
[PDP_linear, RTx, RRx, FadingType, RiceMatrix, RiceFactor_dB, ...
PathLoss_dB, ShadowFading_dB, DirectionOfMovement_rad, ...
Angle_rad, sigma_rad] = ...
IEEE_802_11_Cases(Connection, IEEE_802_11_Case, ...
CorrelationCoefficientType, CarrierFrequency_Hz,...
NumberOfTxAntennas, Spacing_Tx, NumberOfRxAntennas, ...
Spacing_Rx, Distance_Tx_Rx_m);
% Parameters assessment
NumberOfIterations = floor((SimulationLengthInCoherenceTimes/f_D_Hz)/(FadingNumberOfIterations*FadingSamplingTime_s));
NumberOfSamplesPerIteration = floor((FadingNumberOfIterations*FadingSamplingTime_s)/SamplingTime_s);
disp(['Simulation length: ',num2str(SimulationLengthInCoherenceTimes),' coherence times']);
disp([num2str(NumberOfIterations),' vectors of ',num2str(FadingNumberOfIterations),...
' fading samples generated @ ',num2str(FadingSamplingFrequency_Hz),' Hz will be used internally']);
disp(['to produce ', num2str(NumberOfIterations*NumberOfSamplesPerIteration),...
' interpolated samples @ ',num2str(SamplingRate_Hz),' Hz']);
disp(['Oversampling factor of the fades = ',num2str(SamplingRate_Hz),'/',num2str(FadingSamplingFrequency_Hz),' = ',...
num2str(OversamplingFactor)]);
disp([num2str(floor(NumberOfIterations*NumberOfSamplesPerIteration/DownSamplingFactor)),' interpolated',...
' samples will be collected in H and stored in tmp.mat']);
disp(['Sampling frequency of H samples = ',num2str(SamplingRate_Hz),'/',...
num2str(DownSamplingFactor),' = ',num2str(SamplingRate_Hz/DownSamplingFactor),' Hz']);
disp(' ');
% Initialisation of size variable
NumberOfPaths = size(PDP_linear,2);
% Initialisation of fading filter state
% "Dummy" call in order to fill the filter states with realistic values.
% Filters have a very long transient and steady state is achieved after
% 800-1000 filtered samples. Fading samples generated during the transient
% phase should not be used in the channel model, because their variance
% is lower than expected.
[DummyMatrix, FilterStatesOut, RandState] = init_fading_time(1000, ...
NumberOfTxAntennas, NumberOfRxAntennas, NumberOfPaths, FadingType, ...
zeros(Filter_Order,NumberOfTxAntennas*NumberOfRxAntennas*NumberOfPaths), ...
RandState);
clear DummyMatrix;
% Computation of the correlation matrices, one for each tap
[C, R] = init_MIMO_channel(RTx, RRx, CorrelationCoefficientType);
% Initialisation of the LOS component
RiceFactor_linear = 10.^(.1.*RiceFactor_dB);
RiceVectorLOS = [];
RiceVectorNLOS = [];
% Computation of the power delay profile of the (LOS+NLOS) power
% The PDP is defined as the time dispersion of the NLOS power. The addition
% of the LOS component modifies the time dispersion of the total power.
pdp_linear = PDP_linear(1,:).*(1+RiceFactor_linear);
% Normalisation of the power delay profile of the (LOS+NLOS) power
pdp_linear = pdp_linear./sum(pdp_linear);
clear tmp;
tmp = reshape(RiceMatrix, NumberOfTxAntennas*NumberOfRxAntennas, 1);
for (ii = 1:NumberOfPaths)
RiceVectorLOS = [RiceVectorLOS; ...
sqrt(pdp_linear(1,ii)).*sqrt(RiceFactor_linear(ii)/(RiceFactor_linear(ii)+1)).*tmp];
RiceVectorNLOS = [RiceVectorNLOS; sqrt(1/(RiceFactor_linear(ii)+1)).*ones(NumberOfTxAntennas*NumberOfRxAntennas, 1)];
R_index_low = (ii-1)*(NumberOfTxAntennas*NumberOfRxAntennas)+1;
R_index_high = ii*NumberOfTxAntennas*NumberOfRxAntennas;
R(R_index_low:R_index_high,R_index_low:R_index_high) = ...
(RiceFactor_linear(ii)/(RiceFactor_linear(ii)+1)).*(tmp*tmp') ...
+ (1/(RiceFactor_linear(ii)+1)).*R(R_index_low:R_index_high,R_index_low:R_index_high);
end;
% Initialization of fluorescent effects random variables
% Random phase
Random_Phase = rand(1)*2*pi;
% Gaussian random variable
X = randn(1)*GaussianStandardDeviation + GaussianMean;
% Ratio
RandomInterfererToCarrierRatio = X^2;
% Main Loop %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RunningTimeInstant_s = 0;
FadingOffset_s = 0;
TwoLastColumnsOfOldFadingMatrixTime = [];
CorrelatedFading = [];
H = [];
for ii = 1:NumberOfIterations;
% Simulation tracking
time = clock;
disp([num2str(time(4)),':',num2str(time(5)),'.',num2str(floor(time(6))),...
' - Iteration ',num2str(ii),'/',num2str(NumberOfIterations)]);
% Time references
FadingTime_s = FadingOffset_s-((ii~=1)*2*FadingSamplingTime_s):FadingSamplingTime_s:...
FadingOffset_s+((FadingNumberOfIterations-1)*FadingSamplingTime_s);
OversampledFadingTime_s = FadingTime_s(1):.1*FadingSamplingTime_s:...
FadingTime_s(size(FadingTime_s,2));
RunningTime_s = RunningTimeInstant_s:SamplingTime_s:...
(floor((FadingTime_s(1,size(FadingTime_s,2)))/SamplingTime_s)...
-(mod(FadingTime_s(1,size(FadingTime_s,2)),SamplingTime_s)==0))*SamplingTime_s;
HSamples = find((mod(RunningTime_s,DownSamplingFactor*SamplingTime_s)<(.1*SamplingTime_s))|...
(mod(RunningTime_s,DownSamplingFactor*SamplingTime_s)>((DownSamplingFactor-.1)*SamplingTime_s)));
% Computation of the matrix of fading coefficients
[NewFadingMatrixTime, FilterStatesOut, RandState] = init_fading_time(FadingNumberOfIterations, ...
NumberOfTxAntennas, NumberOfRxAntennas, NumberOfPaths, FadingType, ...
FilterStatesOut, RandState);
FadingMatrixTime = [TwoLastColumnsOfOldFadingMatrixTime, NewFadingMatrixTime];
TwoLastColumnsOfOldFadingMatrixTime = NewFadingMatrixTime(:,FadingNumberOfIterations-1:FadingNumberOfIterations);
% Spatial correlation of the fading matrix
FadingMatrixTime = C * FadingMatrixTime;
% Initalisation of normalisation diagonal matrix
pdp_coef = [];
for jj = 1:size(pdp_linear,2)
pdp_coef = [pdp_coef, sqrt(pdp_linear(1,jj)).*ones(1,size(FadingMatrixTime,1)/size(pdp_linear,2))];
end;
% Normalisation of the correlated fading processes
FadingMatrixTime = diag(pdp_coef)*FadingMatrixTime;
% Calculation of the Rice phasor
% AoA/AoD hard-coded to 45 degrees
RicePhasor = exp(j.*2.*pi.*f_D_Hz.*cos(pi/4).*FadingTime_s);
% Addition of the Rice component
FadingMatrixTime = (RiceVectorLOS*RicePhasor)+(RiceVectorNLOS*ones(1,size(FadingMatrixTime,2))).*FadingMatrixTime;
% First (partial) interpolation, at 10*FadingSamplingFrequency_Hz
% to avoid aliasing of the fluorescent effect
OversampledFadingMatrixTime = (interp1(FadingTime_s.',FadingMatrixTime.',OversampledFadingTime_s.','linear')).';
% Call to generate fluorescent light effects in models D and E
if (IEEE_802_11_Case == 'D' | IEEE_802_11_Case == 'E')
OversampledFadingMatrixTime = add_fluorescent_effects(OversampledFadingMatrixTime, IEEE_802_11_Case, ...
PowerLineFrequency_Hz, NumberOfTxAntennas, NumberOfRxAntennas, ...
OversampledFadingTime_s, RandomInterfererToCarrierRatio, Random_Phase);
end;
% Large-scale fading
OversampledFadingMatrixTime = OversampledFadingMatrixTime./sqrt(10.^(.1*(PathLoss_dB+ShadowFading_dB)));
% Second interpolation, at SamplingRate_Hz
CorrelatedFading = (interp1(OversampledFadingTime_s.',OversampledFadingMatrixTime.',RunningTime_s.','linear')).';
H = [H, CorrelatedFading(:,HSamples)];
% Update of book-keeping variables
FadingOffset_s = FadingTime_s(size(FadingTime_s,2))+FadingSamplingTime_s;
RunningTimeInstant_s = RunningTime_s(1,size(RunningTime_s,2))+SamplingTime_s;
end;
temp_H = H;
clear H;
NumberOfHSamples = size(temp_H,2);
H = zeros(NumberOfTxAntennas,NumberOfRxAntennas,NumberOfPaths,NumberOfHSamples);
for ii = 1:size(temp_H,2)
for jj = 1:NumberOfPaths
for kk = 1:NumberOfRxAntennas
for ll = 1:NumberOfTxAntennas
H(ll,kk,jj,ii) = temp_H(((jj-1)*NumberOfTxAntennas+(ll-1))*NumberOfRxAntennas+kk, ii);
end;
end;
end;
end;
save tmp H;
% Validation of MIMO channel %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
plot_MIMO;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -