?? mac_layer.m
字號(hào):
function matrix = MAC_layer (Data_users, SNR_users)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %
%% File: MAC_layer.m %
%% %
%% Function: This routine simulate the MAC layer of the system %
%% %
%% Input: %
%% SNR_users = We don't have the channel estimation process %
%% so we calculate these values on a random process. %
%% Data_users = Amount of data users (coded & mapped: ready) %
%% to be sent. We only have to map them onto a matrix. %
%% %
%% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% You have to input these parameters:
user1 = randint (1,10000);
user2 = randint (1,10000);
user3 = randint (1,10000);
%We iniciate every parameters we are going to use.
Data_users = [user1; user2; user3]; % Data_users has to be a matrix
% I realize that it's probably that each user wants to transmit a
% different amount of data...It has to fix it.
% We have to know, how many users are on the system. We've to know how many
% bits they want to transmit, too. These bits have been coded and mapped so
% they are ready to transmit through the channel.
N_users = size(Data_users,1);
% We want to know which mapping has been applied in each user. We need to
% know what is the SNR of each one. When we mapped the signal, we had to do
% the same thing !!! It has be the same result !!!
% You can change the way we choose the signal mapping...but you've to do
% the same before mapping the signal.
Users_segment = zeros (1,N_users)
for i=1:N_users
if ((SNR_users(i) >= 1) && (SNR_users(i) <= 9))
Users_segment(i) = 0; % We use QPSK mapping
elseif ((SNR_users(i) >= 10) && (SNR_users(i) < 22))
Users_segment(i) = 1; % We use 16-QAM mapping
elseif (SNR_users(i) >= 22)
Users_segment(i) = 2; % We use 64-QAM mapping
end
end
% We Know how many bits are going to transmit each user. We have a FOR
% bucle to do that, because we could have more users on the system.
Amount_Data_users = [];
for i=1:N_users
s = 'user';
Each_user = [s , ('i')]; %we need to concatenate each value...
L = length (Each_user);
Amount_Data_users = [Amount_Data_Users L];
end
Amount_Data_users = [10000 10000 10000]; %You need to cancel this sentence once you do the bule right
% The most important thing is the acknowledgement of the area where each
% user is going to transmit. (Data Region)
[Rest_amount_data_users, data_matrix] = data_region (Amount_Data_users, Users_segment, N_users);
% Now, we have to prepare each subcarrier where we've to put the
% information we want. It is recommendable insert the pilot subcarriers
% later, but we want to know its values now.
% We have to calculate hte values of the pilots subcarriers....
xxxxxxxxx CALCULATE THAT...It Is so easy, because standard give us the way we
have to do that!!
% Now we are going to fill the whole matrix, so the result is going to be a
% matrix which dimensions are 2048x15;
Transmision_Matrix = Filling_matrix (Data_users, data_matrix, pilot_subcarriers);
% Now, we have the whole matrix ready to be send. Before that, we have to
% do the permutation and renumbering stages.
xxxxxxx It isn't so hard. In fact You have already done part of this.
% Finally, we convert our OFDMA symbol data into frequency domain,
% so we've to do an FFT.
OFDMA_symbol = frequency (Transmission_Matrix);
% Frequency has to be a routine where you select each OFDMA symbol, do the
% IFFT process and send it. Remember you have to add the cyclic prefix before send it!!
matrix = OFDMA_symbol;
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -