1.
do_padding
Takes the serial input data and the user specified block size, then checks the serial
data if it can be completely divided into an integer number of blocks. If not, it will add
zeros to the end of the stream until an integer number of blocks can be created.
function [padded_data, no_of_blocks] = do_padding(serial_data, block_size)
% Version 0.1
% Created on September 11, 2004
%
% Check if input data stream can be broken into blocks specified by
% block_size. If not, pad if necessary
% Eror Checking: See that the
if (nargin > 2)
error('create_ofdm_blocks:No_of_arguments_in', 'Too many rows input
arguments. ');
end
if (nargout > 2)
error('create_ofdm_blocks:No_of_arguments_out', 'Too many output
arguments. ');
end
% Find the number of data points in the serial stream
[rows_mod_data cols_mod_data] = size(serial_data);
% Check that the input stream in a 1 x N vector. Exit otherwise
if (rows_mod_data ~= 1)
error( 'create_ofdm_blocks:rows_of_serial_data', 'This has to be a 1 x
N data stream. ');
end
% Find the number of OFDM blocks that can be created based on the user
% input. Divide the number of data points in the stream by the block
% size specified by the user. If there is no remainder after division
% then, there exists an integer number of blocks. Otherwise, create a
% zero-padded block to place the remaining data points
number_of_blocks = floor(length(serial_data)/block_size);
remaining_data_points = rem(length(serial_data), block_size);
if (remaining_data_points == 0)
padded_data = serial_data;
no_of_blocks = length(padded_data)/block_size;
% If the remainder is not equal to zero, put the extra data points in a
% zero padded vector whose length is that of the block size
elseif (remaining_data_points > 0) % start if
% Now find out the position of the remaining points
existing_blocks = floor(length(serial_data)/block_size)
[position_of_rem_pts] =
serial_data((number_of_blocks*block_size)+1:length(serial_data));
% Create zero vector to store remaining points
temp_block = zeros(1, block_size);