Projects STRLCPY wirelesscomm Commits ad5152cc
🤬
  • unit02_propagation/lab_prop_modeling.mlx
    Binary file.
  • unit02_propagation/lab_prop_modeling.pdf
    Binary file.
  • ■ ■ ■ ■ ■ ■
    unit02_propagation/lab_prop_modeling_partial.m
    1  -%% Lab: Fitting Propagation Models from Ray Tracing Data
    2  -% Ray tracing is a widely-used method for predicting wireless coverage
    3  -% in complex indoor and outdoor environments. Ray tracers take a 3D model
    4  -% of some region along with locations of transmitters and can predict the
    5  -% path characteristics from the transmitter locations to specified receiver
    6  -% locations. Ray tracing requires certain assumptions (such as building
    7  -% materials to make the material), so they may not be exact. Nevertheless,
    8  -% they provide an excellent approximation and are often used by cellular
    9  -% carriers to select sites for deploying cells. In this lab, we will use
    10  -% ray tracing outputs to generate a collection of path data from which
    11  -% we can fit analytic models. Ray tracing can provide much more data than
    12  -% would be possible with time-consuming real measurements.
    13  -%
    14  -% In going through this data, you will learn to:
    15  -%
    16  -% * Load and describe ray tracing data produced from a commercial ray
    17  -% tracing tool
    18  -% * Compute the omni-directional path loss from the ray tracing data
    19  -% * Determine if links are in outage (no path), LOS or NLOS
    20  -% * Visualize the path loss and link state as a function of distance
    21  -% * Fit simple models for the path loss and link state using machine
    22  -% learning tools
    23  -%
    24  -% *Submission*: Complete all the sections marked |TODO|, and run the cells
    25  -% to make sure your scipt is working. When you are satisfied with the
    26  -% results, <https://www.mathworks.com/help/matlab/matlab_prog/publishing-matlab-code.html
    27  -% publish your code> to generate an html file. Print the html file to
    28  -% PDF and submit the PDF.
    29  - 
    30  - 
    31  - 
    32  -%% Data from Remcom
    33  -% The data is in this lab was created by NYU MS student Sravan Chintareddy
    34  -% and Research Scientist Marco Mezzavilla. They used a widely-used and
    35  -% powerful commercial ray tracer from <https://www.remcom.com/ Remcom>.
    36  -% Remcom is one of the best ray tracing tools in the industry. Although
    37  -% we will illustrate the concepts at 1.9 GHz carrier, the Remcomm tool is
    38  -% particularly excellent for mmWave studies. Remcom has generously
    39  -% provided their software to NYU for purpose of generating the data for
    40  -% this lab and other research.
    41  -%
    42  -% The data was in this lab comes from a simulation of a section of
    43  -% Reston, VA. In this simulation, a number of transmitters were placed in
    44  -% the area in location similar to possible micro-cellular sites. The
    45  -% receivers were placed on street levels similar to pedestrians (UEs).
    46  -% We can plot the area and the sites with the following.
    47  -A = imread('map.png');
    48  -imshow(A, 'InitialMagnification', 40);
    49  - 
    50  -%% Loading the data
    51  -% We can load the data with the following command.
    52  -% This will create three variables in your workspace.
    53  -%
    54  -% * txpos: A trx x 3 array of the positions of the transmitters
    55  -% * rxpos: An nrx x 3 array of the positions of the receivers
    56  -% * pathTable: A table of all the paths
    57  -load pathData;
    58  - 
    59  -% TODO: Find nrx, ntx and npath
    60  - 
    61  -% TODO: Plot the locations of the TX and RX on the x-y plane.
    62  -% You can ignore the z coordinate of both in the plot. Use different
    63  -% markers (e.g. 'o' and 's' for the TX and RXs).
    64  - 
    65  - 
    66  -%% Determine omni-directional path loss and minimum path delay
    67  -% The table, pathTable, has one row for each path found in the ray tracer.
    68  -% Each path has a TXID and RXID and key statistics like the RX power
    69  -% and delay. Due to multi-path, a (TXID,RXID) pair may have more than
    70  -% one path.
    71  - 
    72  -% TODO: Use the head command to print the first few rows of the path
    73  -% table.
    74  - 
    75  -% TODO: Loop through the paths and create the following arrays,
    76  -% such that for each RXID i and TXID j:
    77  -% pathExists(i,j) = 1 if there exists at least one path
    78  -% totRx(i,j) = total RX power in linear scale
    79  -% minDly(i,j) = minimum path delay (taken from the toa_sec column)
    80  - 
    81  - 
    82  - 
    83  -% TODO: For each link (i,j), compute the omni-directional path loss,
    84  -% which is defined as the txPowdBm - total received power (dBm).
    85  -% In this dataset, txPowdBm = 36
    86  -txPowdBm = 36;
    87  - 
    88  - 
    89  -%% Plot the path loss vs. distance
    90  -% Just to get an idea of the path losses, we plot the omni directional path
    91  -% losses as a function of distance and compare against the FSPL.
    92  - 
    93  - 
    94  -% TODO: Using the arrays rxpos and txpos, compute
    95  -% dist(i,j) = distance between RX i and TX j in meters.
    96  -% Do this without for loops.
    97  - 
    98  -% At this point, you should have nrx x ntx matrices such as dist,
    99  -% plomni, minDly and pathExists. For the subsequent analysis, it is
    100  -% useful to convert these to nrx*ntx x 1 vectors.
    101  -%
    102  -% TODO: Convert dist, plomni, minDly and pathExists to vectors
    103  -% dist1, plomni1, ...
    104  - 
    105  -% TODO: Compute the free-space path loss for 100 points from dmin to dmax.
    106  -% Use the fspl() command.
    107  -dmin = 10;
    108  -dmax = 500;
    109  -fc = 1.9e9; % Carrier frequency
    110  - 
    111  -% TODO: Create a scatter plot of plomni1 vs. dist1 on the links
    112  -% for which there exists a path. On the same plot, plot the FSPL.
    113  -% Use semilogx to put the x axis in log scale. Label the axes.
    114  -% Add a legend.
    115  - 
    116  -% TODO: Plot the path losses
    117  - 
    118  - 
    119  - 
    120  -%% Classify points
    121  -% In many analyses of propagation models, it is useful to classify links as
    122  -% being in LOS, NLOS or outage. Outage means there is no path.
    123  - 
    124  -% TODO: Create a vector Ilink of size nrx*ntx x 1 where
    125  -% linkState(i) = losLink = 1: If the link has a LOS path
    126  -% linkState(i) = nlosLink = 2: If the link has only NLOS paths
    127  -% linkState = nrx*ntx;
    128  -losLink = 0;
    129  -nlosLink = 1;
    130  -outage = 2;
    131  - 
    132  - 
    133  -% TODO: Print the fraction of the links in each of the three states
    134  - 
    135  -%% Plot the path loss vs. distance for the NLOS and LOS links
    136  -% To get an idea for the variation of the path loss vs. distance,
    137  -% we will now plot the omni path loss vs. distance separately for the LOS
    138  -% and NLOS points. You should see that the LOS points are close to the
    139  -% FSPL, but the NLOS points have much higher path loss.
    140  - 
    141  -% TODO: Create a scatter plot of the omni path loss vs. distance
    142  -% using different markers for LOS and NLOS points. On the same graph,
    143  -% plot the FSPL. Label the axes and add a legend.
    144  - 
    145  - 
    146  -%% Linear fit for the path loss model
    147  -% We will now fit a simple linear model of the form,
    148  -%
    149  -% plomni = a + b*10*log10(dist) + xi, xi ~ N(0, sig^2)
    150  -%
    151  -% MATLAB has some basic tools for performing simple model fitting like this.
    152  -% The tools are not as good as sklearn in python, but they are OK.
    153  -% In this case, you can read about the fitlm() command to find the
    154  -% coefficients (a,b) and sig for the LOS and NLOS models. For sig, take
    155  -% the RMSE as the estimate, which is the root mean squared error.
    156  - 
    157  - 
    158  -% TODO: Fit linear models for the LOS and NLOS cases
    159  -% Print the parametrs (a,b,sig) for each model.
    160  - 
    161  - 
    162  -% TODO: Plot the path loss vs. distance for the points for the LOS and
    163  -% NLOS points as before along with the lines for the linear predicted
    164  -% average path loss, a + b*10*log10(dist).
    165  - 
    166  -%% Plotting the link state
    167  -% The final part of the modeling is to understand the probability of a link
    168  -% state as a function of the distance. To visualize this, divide
    169  -% the distances into bins with bin i being
    170  -%
    171  -% [(i-1)*binwid, i*binwid], i = 1,...,nbins
    172  -%
    173  -% We will create an array nbins x 3 arrays:
    174  -%
    175  -% cnt(i,j) = number links whose distance is in bin i and linkState = j
    176  -% cntnorm(i,j)
    177  -% = cnt(i,j) / sum( cnt(i,:) )
    178  -% = fraction of links whose distance is in bin i and linkState = j
    179  -nbins = 10;
    180  -binwid = 50;
    181  -binlim = [0,nbins*binwid];
    182  -bincenter = ((0:nbins-1)' + 0.5)*binwid;
    183  - 
    184  -% TODO: Compute cnt and cntnorm as above. You may use the histcounts
    185  -% function.
    186  - 
    187  - 
    188  -% TODO: Plot cntnorm vs. bincenter using the bar() command with the
    189  -% 'stacked' option. Label the axes and add a legend
    190  - 
    191  - 
    192  -%% Predicting the link state
    193  -% We conclude by fitting a simple model for the probability.
    194  -% We will use a simple multi-class logistic model where, for each link i,
    195  -% the relative probability that linkState(i) == j is given by:
    196  -%
    197  -% log P(linkState(i) == j)/P(linkState(i) == 0)
    198  -% = -B(1,j)*dist1(i) - B(2,j)
    199  -%
    200  -% for j=1,2. Here, B is the matrix of coefficients of the model. So
    201  -% the probability that a link is in a state decays exponentially with
    202  -% distnace. 3GPP uses a slightly different model, but we use this model to
    203  -% make this simple.
    204  -%
    205  -% Fitting logistic models is discussed in the ML class. Here, we will use
    206  -% the MATLAB mnrfit routine.
    207  - 
    208  -% TODO: Use the mnrfit() method to find the coefficients B. You will need
    209  -% to set the response variable to y = linkState + 1 since it expects class
    210  -% labels starting at 1.
    211  - 
    212  - 
    213  -% TODO: Use the mnrval() method to predict the probabilties of each class
    214  -% as a function of distance.
    215  - 
    216  - 
    217  -% TODO: Plot the probabilities as a function of the distance.
    218  -% Label your graph.
    219  - 
    220  - 
    221  -%% Compare the link state
    222  -% Finally, to compare the predicted probabilties with the measured valued,
    223  -% plot the probabilities as a function of the distance on top of the bar
    224  -% graph in a way to see if they are aligned. You should see a good fit
    225  - 
    226  - 
    227  - 
    228  - 
    229  - 
    230  - 
    231  - 
  • unit02_propagation/lab_prop_modeling_partial.pdf
    Binary file.
Please wait...
Page is in error, reload to recover