├── .gitignore ├── Figure1.png ├── Figure2.png ├── LICENSE ├── Normalization.m ├── Normalized_Into_Real_Imag.m ├── Pilot.m ├── README.md ├── autoencoder.m ├── calc_received_Signal.m ├── modifyMat.m ├── parameters.m ├── parameters2.m ├── phaseshiftmatrix.m ├── savechannel.m └── savechannel2.m /.gitignore: -------------------------------------------------------------------------------- 1 | *.meta 2 | git_commit_logs.txt -------------------------------------------------------------------------------- /Figure1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelligentNetworkingLAB/Channel-Estimator/7df17e044f8ea9592eb57102f6d6147700392bf7/Figure1.png -------------------------------------------------------------------------------- /Figure2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntelligentNetworkingLAB/Channel-Estimator/7df17e044f8ea9592eb57102f6d6147700392bf7/Figure2.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2021, IntelligentNetworkingLAB 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /Normalization.m: -------------------------------------------------------------------------------- 1 | num_of_Users = 1810; 2 | num_of_Elements = 64; 3 | num_of_Antennas = 1; 4 | for i = 1:num_of_Antennas 5 | for j = 1:num_of_Elements 6 | for k = 1:num_of_Users 7 | chan_Normalized = zeros(28,612,3); 8 | c_Chan = load("Cascaded\Cascaded_"+i+"_"+j+"_"+k); 9 | c_Matrix = c_Chan.cascaded_Channel; 10 | real = c_Matrix(:,:,1); 11 | imag = c_Matrix(:,:,2); 12 | real_min = min(min(real)); 13 | imag_min = min(min(imag)); 14 | real_Digits = get_Digits(real_min)+1; 15 | imag_Digits = get_Digits(imag_min)+1; 16 | chan_Normalized(:,:,1) = (real + abs(real_min))*10.^real_Digits; 17 | chan_Normalized(:,:,2) = (imag + abs(imag_min))*10.^imag_Digits; 18 | file_Name = "Normalized"+i+"_"+j+"_"+k + "_"+ real_Digits + "_" + imag_Digits; 19 | save("c:\Users\netlab\Desktop\DeepMIMO-5GNR2\Normalized\" + file_Name,'chan_Normalized'); 20 | 21 | end 22 | end 23 | end 24 | 25 | function i = get_Digits(value) 26 | abs_Value = abs(value); 27 | j = 1; 28 | while(abs_Value<1) 29 | abs_Value = abs_Value * 10; 30 | j=j+1; 31 | end 32 | i = j-1; 33 | end 34 | -------------------------------------------------------------------------------- /Normalized_Into_Real_Imag.m: -------------------------------------------------------------------------------- 1 | num_of_Users = 1810; 2 | num_of_Elements = 64; 3 | num_of_Antennas = 1; 4 | for i = 1:num_of_Antennas 5 | for j = 1:num_of_Elements 6 | for k = 1:num_of_Users 7 | chan_normalized_Real = zeros(28,612,1); 8 | chan_normalized_Imag = zeros(28,612,1); 9 | c_Chan = load("Cascaded\Cascaded_"+i+"_"+j+"_"+k); 10 | c_Matrix = c_Chan.cascaded_Channel; 11 | real = c_Matrix(:,:,1); 12 | imag = c_Matrix(:,:,2); 13 | real_min = min(min(real)); 14 | imag_min = min(min(imag)); 15 | real_Digits = get_Digits(real_min)+1; 16 | imag_Digits = get_Digits(imag_min)+1; 17 | chan_Normalized(:,:,1) = (real + abs(real_min))*10.^real_Digits; 18 | chan_Normalized(:,:,2) = (imag + abs(imag_min))*10.^imag_Digits; 19 | chan_normalized_Real = chan_Normalized(:,:,1); 20 | chan_normalized_Imag = chan_Normalized(:,:,2); 21 | file_Name_1 = "Normalized_Real"+i+"_"+j+"_"+k + "_"+ real_Digits + "_" + imag_Digits; 22 | file_Name_2 = "Normalized_Imag"+i+"_"+j+"_"+k + "_"+ real_Digits + "_" + imag_Digits; 23 | save("c:\Users\netlab\Desktop\DeepMIMO-5GNR2\Normalized_Real\" + file_Name_1,'chan_normalized_Real'); 24 | save("c:\Users\netlab\Desktop\DeepMIMO-5GNR2\Normalized_Imag\" + file_Name_2,'chan_normalized_Imag'); 25 | end 26 | end 27 | end 28 | 29 | function i = get_Digits(value) 30 | abs_Value = abs(value); 31 | j = 1; 32 | while(abs_Value<1) 33 | abs_Value = abs_Value * 10; 34 | j=j+1; 35 | end 36 | i = j-1; 37 | end 38 | -------------------------------------------------------------------------------- /Pilot.m: -------------------------------------------------------------------------------- 1 | num_of_Users = 1810; 2 | num_of_Elements = 64; 3 | num_of_Antennas = 1; 4 | 5 | transmitted_Signal = 1+1i; 6 | pilot_Signal = 3+3i; 7 | number_of_Pilot_Symbol = [8 10 12 14]; 8 | Pilot_Spacing = [2 4 6 8]; 9 | 10 | for i = 1:num_of_Antennas 11 | for j = 1:num_of_Elements 12 | for k = 1:num_of_Users 13 | 14 | c_Chan = load("Cascaded\Cascaded_"+i+"_"+j+"_"+k); 15 | channel = c_Chan.cascaded_Channel; 16 | channel_Real = channel(:,:,1); 17 | channel_Imag = channel(:,:,2); 18 | channel_Original = org_Channel(channel_Real,channel_Imag); 19 | dp_Matrix = make_Data_Pilot_Matrix(number_of_Pilot_Symbol,Pilot_Spacing,transmitted_Signal,pilot_Signal); 20 | %transmitted_Signal_Matrix = channel_Original.*dp_Matrix; 21 | file_Name = "Pilot_"+i+"_"+j+"_"+k; 22 | save("c:\Users\netlab\Desktop\DeepMIMO-5GNR2\Pilot\" + file_Name,'dp_Matrix'); 23 | end 24 | end 25 | end 26 | 27 | 28 | 29 | % exampleObject = load("Cascaded\Cascaded_1_10_1"); 30 | % SNRdb = 10; % SNR 10db 31 | % channel = exampleObject.cascaded_Channel; 32 | % transmitted_Signal = 1+1i; 33 | % pilot_Signal = 3+3i; 34 | % channel_Real = channel(:,:,1); 35 | % channel_Imag = channel(:,:,2); 36 | % number_of_Pilot_Symbol = [2 4 6 8 10 12 14]; 37 | % Pilot_Spacing = [2 4 6 8 10 12 14 16 18 20 22 24 26 28 32]; 38 | % SNR = 10^(SNRdb/10); 39 | % channel_Original = org_Channel(channel_Real,channel_Imag); 40 | % dp_Matrix = make_Data_Pilot_Matrix(number_of_Pilot_Symbol,Pilot_Spacing,transmitted_Signal,pilot_Signal); 41 | 42 | function original_Channel = org_Channel(matrix_Real, matrix_Imag) 43 | 44 | symbols = 28; 45 | subCarriers = 612; 46 | 47 | for i = 1:symbols 48 | for j = 1: subCarriers 49 | original_Channel(i,j) = complex(matrix_Real(i,j),matrix_Imag(i,j)); 50 | end 51 | end 52 | 53 | end 54 | 55 | 56 | function data_Pilot_Matrix = make_Data_Pilot_Matrix(sym_Array,carrier_Array,data_Symbol,pilot_Symbol) 57 | 58 | a = randi(size(sym_Array)); 59 | number_of_symbol_for_Pilot = sym_Array(a); % Number of Pilots 60 | 61 | b = randi(size(carrier_Array)); 62 | 63 | symbol_Index = zeros(1,number_of_symbol_for_Pilot); 64 | spacing = carrier_Array(b); 65 | 66 | for r = 1:number_of_symbol_for_Pilot 67 | if(r>1) 68 | 69 | while(true) 70 | symbol_Index(r) = randi(28); 71 | chk = 0; 72 | for m = 1:r-1 73 | if(symbol_Index(m)==symbol_Index(r)) 74 | chk = 1; 75 | break; 76 | else 77 | chk=0; 78 | end 79 | end 80 | 81 | if(chk==0) 82 | break; 83 | end 84 | end 85 | else 86 | symbol_Index(r) = randi(28); 87 | end 88 | end 89 | 90 | for i = 1:28 91 | for j = 1:612 92 | data_Pilot_Matrix(i,j) = data_Symbol; 93 | end 94 | end 95 | 96 | for l = 1:number_of_symbol_for_Pilot 97 | 98 | pilot_Index = symbol_Index(l); 99 | 100 | for k = 1:20 101 | 102 | 103 | index = spacing * k; 104 | 105 | if(index>612) 106 | break; 107 | end 108 | 109 | data_Pilot_Matrix(pilot_Index,index) = pilot_Symbol; 110 | 111 | end 112 | 113 | 114 | end 115 | 116 | end 117 | 118 | % function received_Signal = wireless_Channel() 119 | % 120 | % 121 | % end 122 | 123 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Autoencoder-based Channel Estimator 2 | Accurate channel estimation is an essential factor in determining the efficiency of a wireless communication system. Moreover, in Reconfigurable Intelligent Surfaces(RIS)-Assisted wireless networks using millimeter wave(mmWave), it is crucial to optimize each RIS element's phase shift. Therefore, in this paper, we propose a channel estimation method in TDD-based wireless communication system using autoencoder in RIS-Assisted wireless networks. The trade-off relationship between channel estimation accuracy and the number of pilot signals is optimized when performing channel estimation. Through denoising autoencoder and Average Percentage of Zeros(APoZ), we find the optimal pilot pattern considering not only the number of pilots but also the location. As a result of the experiment, the proposed method has little difference in performance or outperforms the full neural network without pruning. 3 | 4 | ![image info](./Figure1.png) 5 | ![image info](./Figure2.png) 6 | 7 | An autoencoder is a neural network that copies input to an output and consists of two parts : an encoder and a decoder. The encoder part also called a recognition network, transforms the input into an internal representation, and the decoder, also called a generative network, transforms the internal representation into an output. It is a simple neural network, but it makes a complex neural network by constraining the autoencoder network in various ways. These constraints prevent the autoencoder from simply copying the input directly to the output and controlling it to learn how to represent the data efficiently. 8 | 9 | # Needed Tools and Versions 10 | - Matlab R2022a 11 | - 5G Toolbox 12 | - Deep Learning Toolbox 13 | 14 | # License 15 | Copyright (c) 2021 Networking Intelligence 16 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 17 | 18 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 19 | 20 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | -------------------------------------------------------------------------------- /autoencoder.m: -------------------------------------------------------------------------------- 1 | %chanDatasetPath = fullfile(matlabroot,'toolbox','nnet', ... 2 | % 'nndemos','nndatasets','DigitDataset'); 3 | 4 | imagesDir = "c:\Users\netlab\Desktop\DeepMIMO-5GNR2\Normalized_Real\"; 5 | 6 | imds = imageDatastore(imagesDir,'ReadFcn',@matRead,'FileExtensions','.mat', ... 7 | 'IncludeSubfolders',true, ... 8 | 'LabelSource','foldernames'); 9 | 10 | imds.ReadSize = 500; 11 | imds = shuffle(imds); 12 | 13 | [imdsTrain,imdsVal,imdsTest] = splitEachLabel(imds,0.95,0.025); 14 | 15 | dsTrainNoisy = transform(imdsTrain,@addNoise); 16 | dsValNoisy = transform(imdsVal,@addNoise); 17 | dsTestNoisy = transform(imdsTest,@addNoise); 18 | 19 | dsTrain = combine(dsTrainNoisy,imdsTrain); 20 | dsVal = combine(dsValNoisy,imdsVal); 21 | dsTest = combine(dsTestNoisy,imdsTest); 22 | 23 | dsTrain = transform(dsTrain,@commonPreprocessing); 24 | dsVal = transform(dsVal,@commonPreprocessing); 25 | dsTest = transform(dsTest,@commonPreprocessing); 26 | 27 | % dsTrain = transform(dsTrain,@augmentImages); 28 | 29 | exampleData = preview(dsTrain); 30 | inputs = exampleData(:,1); 31 | responses = exampleData(:,2); 32 | minibatch = cat(2,inputs,responses); 33 | montage(minibatch','Size',[8 2]) 34 | title('Inputs (Left) and Responses (Right)') 35 | 36 | 37 | imageLayer = imageInputLayer([28,120,1]); 38 | 39 | encodingLayers = [ ... 40 | convolution2dLayer(3,16,'Padding','same'), ... 41 | reluLayer, ... 42 | maxPooling2dLayer(2,'Padding','same','Stride',2), ... 43 | convolution2dLayer(3,8,'Padding','same'), ... 44 | reluLayer, ... 45 | maxPooling2dLayer(2,'Padding','same','Stride',2), ... 46 | convolution2dLayer(3,8,'Padding','same'), ... 47 | reluLayer, ... 48 | maxPooling2dLayer(2,'Padding','same','Stride',2)]; 49 | 50 | decodingLayers = [ ... 51 | createUpsampleTransponseConvLayer(2,8), ... 52 | reluLayer, ... 53 | createUpsampleTransponseConvLayer(2,8), ... 54 | reluLayer, ... 55 | createUpsampleTransponseConvLayer(2,16), ... 56 | reluLayer, ... 57 | convolution2dLayer(3,1,'Padding','same'), ... 58 | clippedReluLayer(1.0), ... 59 | regressionLayer]; 60 | 61 | layers = [imageLayer,encodingLayers,decodingLayers]; 62 | 63 | % options = trainingOptions('adam', ... 64 | % 'MaxEpochs',100, ... 65 | % 'MiniBatchSize',imds.ReadSize, ... 66 | % 'ValidationData',dsVal, ... 67 | % 'Plots','training-progress', ... 68 | % 'Verbose',false); 69 | 70 | deepNetworkDesigner(layers); 71 | %net = trainNetwork(dsTrain,layers,options); 72 | 73 | %modelDateTime = string(datetime('now','Format',"yyyy-MM-dd-HH-mm-ss")); 74 | %save(strcat("trainedImageToImageRegressionNet-",modelDateTime,".mat"),'net'); 75 | 76 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 77 | 78 | function dataOut = addNoise(data) 79 | 80 | dataOut = data; 81 | for idx = 1:size(data,1) 82 | dataOut{idx} = imnoise(data{idx},'salt & pepper'); 83 | end 84 | 85 | end 86 | 87 | function dataOut = addNoise_2(data) 88 | 89 | %dataOut = data; 90 | n_of_blank = randi([10,40],1); 91 | 92 | 93 | for idx = 1:size(data,1) 94 | data_Temp = data{idx}; 95 | chan_Image_Trunc_1 = data_Temp(:,:,1); 96 | chan_Image_Trunc_2 = data_Temp(:,:,2); 97 | chan_Image_Trunc_3 = data_Temp(:,:,3); 98 | 99 | for j = 1:256 100 | for k = 1:n_of_blank 101 | y_axis = randi([1,64]); 102 | chan_Image_Trunc_1(j,y_axis)=0; 103 | chan_Image_Trunc_2(j,y_axis)=0; 104 | end 105 | end 106 | 107 | dataOut(:,:,1) = chan_Image_Trunc_1; 108 | dataOut(:,:,2) = chan_Image_Trunc_2; 109 | dataOut(:,:,3) = 0.5500; 110 | 111 | end 112 | 113 | end 114 | 115 | function dataOut = commonPreprocessing(data) 116 | 117 | dataOut = cell(size(data)); 118 | for col = 1:size(data,2) 119 | for idx = 1:size(data,1) 120 | temp = single(data{idx,col}); 121 | %temp = imresize(temp,[180,28]); 122 | %temp = rescale(temp); 123 | dataOut{idx,col} = temp; 124 | end 125 | end 126 | end 127 | 128 | function dataOut = augmentImages(data) 129 | 130 | dataOut = cell(size(data)); 131 | for idx = 1:size(data,1) 132 | rot90Val = randi(4,1,1)-1; 133 | dataOut(idx,:) = {rot90(data{idx,1},rot90Val),rot90(data{idx,2},rot90Val)}; 134 | end 135 | end 136 | 137 | function out = createUpsampleTransponseConvLayer(factor,numFilters) 138 | 139 | filterSize = 2*factor - mod(factor,2); 140 | cropping = (factor-mod(factor,2))/2; 141 | numChannels = 1; 142 | 143 | out = transposedConv2dLayer(filterSize,numFilters, ... 144 | 'NumChannels',numChannels,'Stride',factor,'Cropping',cropping); 145 | end 146 | 147 | function data = matRead(filename) 148 | inp = load(filename); 149 | f = fields(inp); 150 | data = inp.(f{1}); 151 | end -------------------------------------------------------------------------------- /calc_received_Signal.m: -------------------------------------------------------------------------------- 1 | 2 | function chan = -------------------------------------------------------------------------------- /modifyMat.m: -------------------------------------------------------------------------------- 1 | exampleObject = matfile('Raytracing_scenarios\O1_28\O1_28.TX_Loc.mat','Writable',true); 2 | varlist=who(exampleObject); 3 | -------------------------------------------------------------------------------- /parameters.m: -------------------------------------------------------------------------------- 1 | %%%% DeepMIMO parameters set %%%% 2 | % A detailed description of the parameters is available on DeepMIMO.net 3 | 4 | %Ray-tracing scenario 5 | params.scenario = 'O1_28'; % The adopted ray tracing scenario [check the available scenarios at https://deepmimo.net/scenarios/] 6 | 7 | %Dynamic Scenario Scenes [only for dynamic (multiple-scene) scenarios] 8 | params.scene_first = 1; 9 | params.scene_last = 1; 10 | 11 | % Active base stations 12 | params.active_BS = [3]; % Includes the numbers of the active BSs (values from 1-18 for 'O1')(check the scenario description at https://deepmimo.net/scenarios/ for the BS numbers) 13 | 14 | % Active users 15 | params.active_user_first = 850; % The first row of the considered user section (check the scenario description for the user row map) 16 | params.active_user_last = 850; % The last row of the considered user section (check the scenario description for the user row map) 17 | 18 | % Subsampling of active users 19 | %--> Setting both subsampling parameters to 1 activate all the users indicated previously 20 | params.row_subsampling = 1; % Randomly select round(row_subsampling*(active_user_last-params.active_user_first)) rows 21 | params.user_subsampling = 1; % Randomly select round(user_subsampling*number_of_users_in_row) users in each row 22 | 23 | params.enable_BS2BSchannels = 0; % Enable generating BS to BS channel (could be useful for IAB, RIS, repeaters, etc.) 24 | params.num_paths = 3; % Maximum number of paths to be considered (a value between 1 and 25), e.g., choose 1 if you are only interested in the strongest path 25 | 26 | % If 5G toolbox is activated, the relevant previous parameters will be overridden 27 | params.CDL_5G.NRB = 51; % Number of NR blocks 28 | params.CDL_5G.SCS = 30; % kHz - Subcarrier Spacing 29 | 30 | % OFDM parameters 31 | params.OFDM_sampling_factor = 1; % The constructed channels will be calculated only at the sampled subcarriers (to reduce the size of the dataset) 32 | params.OFDM_limit = 612; % Only the first params.OFDM_limit subcarriers will be considered when constructing the channels 33 | 34 | % UE Movement Model 35 | % The maximum Doppler shift will be determined from the velocity 36 | % i.e., max_doppler =(params_user.velocity/3.6)/physconst('lightspeed')*f_carrier 37 | % For a fixed velocity, select a scalar value. 38 | % For random velocity selection for each user, 39 | % set it to [min_vel, max_vel] and it will take a uniform random value in (min_vel, max_vel) 40 | params.CDL_5G.Velocity = [1, 20]; % UE velocity in km/h - 41 | 42 | % UE travel direction in degrees 43 | % If a 1x2 vector is given in the format [azimuth; zenith], the direction is fixed. E.g., [0; 90] corresponds to +x 44 | % If a 2x2 matrix of [min_az, max_az; min_zen, max_zen] is given 45 | % it will be uniformly randomly sampled for each user. 46 | params.CDL_5G.UTDirectionOfTravel = [0, 360; 90, 90]; 47 | 48 | % Number of consecutive OFDM slots to be sampled. 49 | % - 14*num_slots channel time samples will be returned - 50 | params.CDL_5G.num_slots = 2; 51 | 52 | % The LOS path (if there is any in the ray-tracing) is split into Rician paths with the K-factor. 53 | % 13.3dB is the CDL-D channel K factor given in 3GPP 38.901 7.7.1-4. 54 | % 22dB is the CDL-E channel K factor given in 3GPP 38.901 7.7.1-5. 55 | params.CDL_5G.KFactorFirstCluster = 13.3; 56 | 57 | % Cross-polarization power ratio in dB 58 | % The values defined in 3GPP 38.901 are 59 | % CDL-A: 10, CDL-B: 8, CDL-C: 7, CDL-D: 11, CDL-E: 8. 60 | params.CDL_5G.XPR = 10; 61 | 62 | %%%%%%%%%%%%%%%%%%%%%%%%%% Antenna Definiton %%%%%%%%%%%%%%%%%%%%%%%%%% 63 | % Antenna Arrays of Isotropic Elements 64 | % Orientation: 65 | params.CDL_5G.bsArrayOrientation = [0, 0]; 66 | % Azimuth (0 deg is array look direction +x, 90 deg is +y) and elevation (positive points upwards) in deg 67 | % If there are multiple active antennas are available, and different 68 | % orientations are targeted, rows of orientations can be given. 69 | % E.g., with 2 active antennas, we can set: 70 | % params.CDL_5G.bsArrayOrientation = [[0, 0]; [90, 0]]; 71 | 72 | params.CDL_5G.ueArrayOrientation = [-180, 0]; 73 | % Azimuth (0 deg is array look direction +x, 90 deg is +y) and elevation (positive points upwards) in deg 74 | % For a random UE orientation, set [az_min, az_max; el_min, el_max]. 75 | % The azimuth and elevation directions are uniformly sampled from [az_min, az_max] and [el_min, el_max]. 76 | % E.g., params.CDL_5G.ueArrayOrientation = [0, 360; 0, 60]; 77 | % The resulting array orientation of a UE can be viewed at path_params.ueArrayOrientation 78 | 79 | % Antenna panel size: 80 | params.CDL_5G.bsAntSize = [8, 8]; % Number of rows and columns in rectangular BS array 81 | % If there are multiple active antennas are available, and different 82 | % antennta sizes are targeted, rows of different panel sizes can be given. 83 | % E.g., with 2 active antennas, we can set: 84 | % params.CDL_5G.bsAntSize = [[4, 8]; [2, 2]]; 85 | 86 | params.CDL_5G.ueAntSize = [1, 1]; % Number of rows and columns in the rectangular UE array 87 | 88 | 89 | params.CDL_5G.polarization = 0; % Polarization 90 | % Setting it to 1 places 2 cross polarized antennas for each antenna element in the array. 91 | % In this case, there will be twice the number of antennas selected in 92 | % ueAntSize and bsAntSize parameters. 93 | % For instance, if bsAntSize = [4,8] and polarization is 1, the transmitter will have 64 antennas. 94 | % Similary, the ueAntSize is doubled with the polarization. 95 | 96 | % Custom Antenna Array Definition with Phased Array Toolbox 97 | % 98 | % If the indicator is activated, the following custom antenna objects 99 | % will be adopted by the CDL model. This way, directive 100 | % and different shapes of antenna arrays can be defined. 101 | % 102 | % The details of the Phased Array System Toolbox 103 | % can be found at https://www.mathworks.com/help/phased/index.html. 104 | params.CDL_5G.customAntenna = 0; 105 | if params.CDL_5G.customAntenna 106 | % Calculate wavelength for defining custom antenna object 107 | carrier_frequency = 60; %GHz 108 | lambda = carrier_frequency*1e9/physconst('LightSpeed'); 109 | 110 | % Example UPA with (0.5*lambda) spacing in both directions 111 | params.CDL_5G.bsCustomAntenna = phased.URA('Size', [4, 8], 'ElementSpacing', 0.5*lambda*[1, 1]); 112 | 113 | % If there are multiple BS antennas activated, it can be 114 | % defined as a cell of the antennas corresponding to each active BS. 115 | % Example: 116 | % antenna1 = phased.URA('Size', [2 2], 'ElementSpacing', 0.5*lambda*[1 1]); 117 | % antenna2 = phased.URA('Size', [4 4], 'ElementSpacing', 0.5*lambda*[1 1]); 118 | % params.CDL_5G.bsCustomAntenna = {antenna1, antenna2}; 119 | 120 | params.CDL_5G.ueCustomAntenna = phased.URA('Size', [2, 2], 'ElementSpacing', 0.5*lambda*[1, 1]); 121 | end 122 | 123 | params.saveDataset=0; -------------------------------------------------------------------------------- /parameters2.m: -------------------------------------------------------------------------------- 1 | %%%% DeepMIMO parameters set %%%% 2 | % A detailed description of the parameters is available on DeepMIMO.net 3 | 4 | %Ray-tracing scenario 5 | params.scenario = 'O1_28'; % The adopted ray tracing scenario [check the available scenarios at https://deepmimo.net/scenarios/] 6 | 7 | %Dynamic Scenario Scenes [only for dynamic (multiple-scene) scenarios] 8 | params.scene_first = 1; 9 | params.scene_last = 1; 10 | 11 | % Active base stations 12 | params.active_BS = [3]; % Includes the numbers of the active BSs (values from 1-18 for 'O1')(check the scenario description at https://deepmimo.net/scenarios/ for the BS numbers) 13 | 14 | % Active users 15 | params.active_user_first = 1001; % The first row of the considered user section (check the scenario description for the user row map) 16 | params.active_user_last = 1010; % The last row of the considered user section (check the scenario description for the user row map) 17 | 18 | % Subsampling of active users 19 | %--> Setting both subsampling parameters to 1 activate all the users indicated previously 20 | params.row_subsampling = 1; % Randomly select round(row_subsampling*(active_user_last-params.active_user_first)) rows 21 | params.user_subsampling = 1; % Randomly select round(user_subsampling*number_of_users_in_row) users in each row 22 | 23 | params.enable_BS2BSchannels = 0; % Enable generating BS to BS channel (could be useful for IAB, RIS, repeaters, etc.) 24 | params.num_paths = 3; % Maximum number of paths to be considered (a value between 1 and 25), e.g., choose 1 if you are only interested in the strongest path 25 | 26 | % If 5G toolbox is activated, the relevant previous parameters will be overridden 27 | params.CDL_5G.NRB = 51; % Number of NR blocks 28 | params.CDL_5G.SCS = 30; % kHz - Subcarrier Spacing 29 | 30 | % OFDM parameters 31 | params.OFDM_sampling_factor = 1; % The constructed channels will be calculated only at the sampled subcarriers (to reduce the size of the dataset) 32 | params.OFDM_limit = 612; % Only the first params.OFDM_limit subcarriers will be considered when constructing the channels 33 | 34 | % UE Movement Model 35 | % The maximum Doppler shift will be determined from the velocity 36 | % i.e., max_doppler =(params_user.velocity/3.6)/physconst('lightspeed')*f_carrier 37 | % For a fixed velocity, select a scalar value. 38 | % For random velocity selection for each user, 39 | % set it to [min_vel, max_vel] and it will take a uniform random value in (min_vel, max_vel) 40 | params.CDL_5G.Velocity = [1, 20]; % UE velocity in km/h - 41 | 42 | % UE travel direction in degrees 43 | % If a 1x2 vector is given in the format [azimuth; zenith], the direction is fixed. E.g., [0; 90] corresponds to +x 44 | % If a 2x2 matrix of [min_az, max_az; min_zen, max_zen] is given 45 | % it will be uniformly randomly sampled for each user. 46 | params.CDL_5G.UTDirectionOfTravel = [0, 360; 90, 90]; 47 | 48 | % Number of consecutive OFDM slots to be sampled. 49 | % - 14*num_slots channel time samples will be returned - 50 | params.CDL_5G.num_slots = 2; 51 | 52 | % The LOS path (if there is any in the ray-tracing) is split into Rician paths with the K-factor. 53 | % 13.3dB is the CDL-D channel K factor given in 3GPP 38.901 7.7.1-4. 54 | % 22dB is the CDL-E channel K factor given in 3GPP 38.901 7.7.1-5. 55 | params.CDL_5G.KFactorFirstCluster = 13.3; 56 | 57 | % Cross-polarization power ratio in dB 58 | % The values defined in 3GPP 38.901 are 59 | % CDL-A: 10, CDL-B: 8, CDL-C: 7, CDL-D: 11, CDL-E: 8. 60 | params.CDL_5G.XPR = 10; 61 | 62 | %%%%%%%%%%%%%%%%%%%%%%%%%% Antenna Definiton %%%%%%%%%%%%%%%%%%%%%%%%%% 63 | % Antenna Arrays of Isotropic Elements 64 | % Orientation: 65 | params.CDL_5G.bsArrayOrientation = [0, 0]; 66 | % Azimuth (0 deg is array look direction +x, 90 deg is +y) and elevation (positive points upwards) in deg 67 | % If there are multiple active antennas are available, and different 68 | % orientations are targeted, rows of orientations can be given. 69 | % E.g., with 2 active antennas, we can set: 70 | % params.CDL_5G.bsArrayOrientation = [[0, 0]; [90, 0]]; 71 | 72 | params.CDL_5G.ueArrayOrientation = [-180, 0]; 73 | % Azimuth (0 deg is array look direction +x, 90 deg is +y) and elevation (positive points upwards) in deg 74 | % For a random UE orientation, set [az_min, az_max; el_min, el_max]. 75 | % The azimuth and elevation directions are uniformly sampled from [az_min, az_max] and [el_min, el_max]. 76 | % E.g., params.CDL_5G.ueArrayOrientation = [0, 360; 0, 60]; 77 | % The resulting array orientation of a UE can be viewed at path_params.ueArrayOrientation 78 | 79 | % Antenna panel size: 80 | params.CDL_5G.bsAntSize = [8, 8]; % Number of rows and columns in rectangular BS array 81 | % If there are multiple active antennas are available, and different 82 | % antennta sizes are targeted, rows of different panel sizes can be given. 83 | % E.g., with 2 active antennas, we can set: 84 | % params.CDL_5G.bsAntSize = [[4, 8]; [2, 2]]; 85 | 86 | params.CDL_5G.ueAntSize = [1, 1]; % Number of rows and columns in the rectangular UE array 87 | 88 | 89 | params.CDL_5G.polarization = 0; % Polarization 90 | % Setting it to 1 places 2 cross polarized antennas for each antenna element in the array. 91 | % In this case, there will be twice the number of antennas selected in 92 | % ueAntSize and bsAntSize parameters. 93 | % For instance, if bsAntSize = [4,8] and polarization is 1, the transmitter will have 64 antennas. 94 | % Similary, the ueAntSize is doubled with the polarization. 95 | 96 | % Custom Antenna Array Definition with Phased Array Toolbox 97 | % 98 | % If the indicator is activated, the following custom antenna objects 99 | % will be adopted by the CDL model. This way, directive 100 | % and different shapes of antenna arrays can be defined. 101 | % 102 | % The details of the Phased Array System Toolbox 103 | % can be found at https://www.mathworks.com/help/phased/index.html. 104 | params.CDL_5G.customAntenna = 0; 105 | if params.CDL_5G.customAntenna 106 | % Calculate wavelength for defining custom antenna object 107 | carrier_frequency = 60; %GHz 108 | lambda = carrier_frequency*1e9/physconst('LightSpeed'); 109 | 110 | % Example UPA with (0.5*lambda) spacing in both directions 111 | params.CDL_5G.bsCustomAntenna = phased.URA('Size', [4, 8], 'ElementSpacing', 0.5*lambda*[1, 1]); 112 | 113 | % If there are multiple BS antennas activated, it can be 114 | % defined as a cell of the antennas corresponding to each active BS. 115 | % Example: 116 | % antenna1 = phased.URA('Size', [2 2], 'ElementSpacing', 0.5*lambda*[1 1]); 117 | % antenna2 = phased.URA('Size', [4 4], 'ElementSpacing', 0.5*lambda*[1 1]); 118 | % params.CDL_5G.bsCustomAntenna = {antenna1, antenna2}; 119 | 120 | params.CDL_5G.ueCustomAntenna = phased.URA('Size', [2, 2], 'ElementSpacing', 0.5*lambda*[1, 1]); 121 | end 122 | 123 | params.saveDataset=0; -------------------------------------------------------------------------------- /phaseshiftmatrix.m: -------------------------------------------------------------------------------- 1 | phaseshift_Matrix = zeros(28,612,1); 2 | 3 | for i = 1:28 4 | 5 | for j = 1:612 6 | 7 | phaseshift_Matrix(i,j) = 1 * exp(pi/2 * 1i); 8 | 9 | end 10 | 11 | end 12 | 13 | file_Name = "Phaseshift_Matrix"; 14 | save("c:\Users\netlab\Desktop\DeepMIMO-5GNR2\PhaseshiftMat\" + file_Name,'phaseshift_Matrix'); -------------------------------------------------------------------------------- /savechannel.m: -------------------------------------------------------------------------------- 1 | bs = 1; 2 | total_Users = 181; 3 | channel_Matrix = zeros(28,612,3); 4 | ue=90; 5 | 6 | for bs_Antenna = 1:1 7 | for ris_Antenna = 1:64 8 | channel = DeepMIMO_dataset{bs}.user{ue}.channel; 9 | channel_plot = squeeze(channel(:, bs_Antenna, ris_Antenna, :)); 10 | subcarriers = 1:dataset_params.OFDM_sampling_factor:dataset_params.OFDM_limit; 11 | OFDM_symbols = 1:1:(14*dataset_params.CDL_5G.num_slots); 12 | channel_plot_r = real(channel_plot); 13 | channel_plot_i = imag(channel_plot); 14 | channel_Matrix(:,:,1) = channel_plot_r; 15 | channel_Matrix(:,:,2) = channel_plot_i; 16 | file_Name = "True" + bs_Antenna + "to" + ris_Antenna + ".mat"; 17 | save("c:\Users\netlab\Desktop\DeepMIMO-5GNR2\Channel_BS_to_RIS\" + file_Name,'channel_Matrix'); 18 | end 19 | end 20 | 21 | % figure; 22 | % 23 | % subplot(2 ,1, 1); 24 | % surf(OFDM_symbols, subcarriers, channel_plot'); 25 | % shading('flat'); 26 | % xlabel('OFDM Symbols'); 27 | % ylabel('Subcarriers'); 28 | % zlabel('|H|'); 29 | % title('Channel Magnitude Response'); 30 | % view(-75, 35) 31 | % 32 | % 33 | % subplot(2,1,2); 34 | % imagesc(OFDM_symbols, subcarriers, channel_plot'); 35 | % set(gca,'YDir','normal') % Invert Y axis (subcarriers) 36 | % shading('flat'); 37 | % xlabel('OFDM Symbols'); 38 | % ylabel('Subcarriers'); 39 | % zlabel('|H|'); 40 | % title('Channel Magnitude Response'); 41 | % view(0, 90) -------------------------------------------------------------------------------- /savechannel2.m: -------------------------------------------------------------------------------- 1 | bs = 1; 2 | total_Users = 1810; 3 | channel_Matrix = zeros(28,612,3); 4 | 5 | for i = 1:total_Users 6 | for ris_Antenna = 1 : 64 7 | channel = DeepMIMO_dataset{bs}.user{i}.channel; 8 | channel_plot = (squeeze(channel(:, 1, ris_Antenna, :))); 9 | [l,c] = size(channel_plot); 10 | 11 | if l ~= 28 12 | i = i+1; 13 | else 14 | subcarriers = 1:dataset_params.OFDM_sampling_factor:dataset_params.OFDM_limit; 15 | OFDM_symbols = 1:1:(14*dataset_params.CDL_5G.num_slots); 16 | channel_plot_r = real(channel_plot); 17 | channel_plot_i = imag(channel_plot); 18 | channel_Matrix(:,:,1) = channel_plot_r; 19 | channel_Matrix(:,:,2) = channel_plot_i; 20 | file_Name = "True_" + "RIS_Antenna_" + ris_Antenna + "_to_UE_" + i + ".mat"; 21 | save("c:\Users\netlab\Desktop\DeepMIMO-5GNR2\Channel_RIS_to_UE\" + file_Name,'channel_Matrix'); 22 | end 23 | end 24 | end --------------------------------------------------------------------------------