function ECE1020_Comp10addnoise
% By Neil E. Cotter, 22 July 2002.
% Students will not write this function.
% This function reads in students' transmitted bits and adds
%  noise before saving.
% Input filename = xmit_code_bits.mat  (read in by load command)
% Output filename = noisy_xmit_data.txt  (stord by dlmwrite with comma delim)


% Clear command_code so we can see if it is read in properly.
command_code = [];

%%%%%% Read transmitted codewords in from file using load command.
%  Info is save in file called xmit_code_bits.mat
load('xmit_code_bits','command_code');

% Print command_code.
command_code = command_code;

% Create noise vector to randomly twiddle transmitted bits.
noise = randn(1,length(command_code))*0.25;

% Twiddle the bits in command_code.
command_recv = command_code + noise;

%%%%%% Save noisy transmitted bits in file called noisy_xmit_data.txt.
dlmwrite('noisy_xmit_data.txt', command_recv, ',');

return

