function data = source(fr_length,frames,md,zf,mode,varargin) %SOURCE Generate source data. % DATA = SOURCE(FR_LENGTH,FRAMES,MD,ZF,MODE) creates data % source of desired number of FRAMES each consists of % FR_LENGTH symbols. MD determines the range of integers (data) % the frame will be filled with. For instance of MD = 4 and random % MODE the DATA will contain numbers within a set {0,1,2,3}. % ZF corresponds to the length of zeros that will be appended % at the end of each frame. This ensures the encoder will be % forced into the zero state at the beginning and end of each frame. % An optional source pattern may be specified via MODE variable. % Possible values for MODE are 'Random'|'Ramp'|'Const'. When the % option 'Const' is chosen than MODE must be followed with desired % value. This corresponds to the frame with constant codeword. % % DATA = SOURCE(...,'EchoOn') toggles internal function echo on. % % See also SPACE. % Copyright 2001-2002 Kamil Anis, anisk@feld.cvut.cz % Dept. of Radioelectronics, % Faculty of Electrical Engineering % Czech Technical University in Pragu % $Revision: 2.0 $ $Date: 2002/10/23 17:33:28 $ % -- % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BODY BEGIN %%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% switch mode case 'Random' data = round((md - 1) * rand(fr_length,1,frames)); case 'Ramp' ramp = mod([1:fr_length] - 1,md)'; data = repmat(ramp,[1 1 frames]); case 'Const' data = varargin{1} * ones(fr_length,1,frames); end % zero forcing appendix [m,n,o] = size(data); n = m + 1:m + zf; data(n,:,1:o) = 0; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BODY END %%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if (isempty(varargin) == 0) & (varargin{end} == 'EchoOn') [indent,gap,name] = iprompt('SOURCE:'); str1 = num2str(frames); str2 = num2str(fr_length); str3 = num2str(zf); disp(' '); disp([name,gap,mode,' data -> ',str1,' frame(s) by ',str2,... ' symbols; ',str3,' zeros appended.']); disp(' '); end