function x = unitsig(seq,N,delay) % unitsig --> Unit sample, unit step, and unit ramp sequences. % % % x = unitsig(seq,N,delay) % % % Generates an N-vector, which is a unit sample (delta), % unit step, or unit ramp sequence, if seq = 'delta', % 'step', or 'ramp', respectively. The argument, delay, % is the number of zero-valued samples in the beginning % of the sequences. % % % sinsig --> Sum of sinusoidal sequences. % rectsig --> Sum of square wave sequences. % trisig --> Sum of sawtooth wave sequences. % % Peter S.K. Hansen, IMM, Technical University of Denmark % % Last revised: February 7, 2000 %----------------------------------------------------------------------- % Check the required input arguments. if (nargin < 2) error('Not enough input arguments.') elseif (nargin == 2) delay = 0; end if (delay >= N) error('The delay must be less than the sequence length N.') end % Generate the sequence. if (seq(1)=='d') % Delta sequence. x = [zeros(delay,1); 1; zeros(N-delay-1,1)]; elseif (seq(1)=='s') % Unit step sequence. x = [zeros(delay,1); ones(N-delay,1)]; elseif (seq(1)=='r') % Unit ramp sequence. x = [zeros(delay,1); (0:(N-delay-1))']; end %----------------------------------------------------------------------- % End of function unitsig %-----------------------------------------------------------------------