function x = trisig(N,fp,A,offset,width) % trisig --> Sum of sawtooth wave sequences. % % % x = trisig(N,fp) % x = trisig(N,fp,A) % x = trisig(N,fp,A,offset) % x = trisig(N,fp,A,offset,width) % % % Generates an N-vector, which is a sum of K sawtooth wave % sequences. The period frequencies are given by the K-vector % fp, where the elements -0.5 < fp(k) < 0.5 are the normalized % period frequencies, i.e., the 'analog' period frequency divided % by the sampling frequency. The K-vector A is the peak values, % and the K-vector offset is the percents in which the periods % are offset from zero. If any of the input arguments fp, A, % and offset is a scalar, then the value will be applied to all % the sawtooth wave sequences. The scalar, width, is the % percent of the period in which the signal increases from % -A to A. % % % sinsig --> Sum of sinusoidal sequences. % rectsig --> Sum of square wave sequences. % % Peter S.K. Hansen, IMM, Technical University of Denmark % % Last revised: February 7, 2000 %----------------------------------------------------------------------- % Check the required input arguments and set defaults. if (nargin < 2) error('Not enough input arguments.') end if (nargin < 3) A = 1; end if (nargin < 4) offset = 0; end if (nargin < 5) width = 50; end % Make sure that parameter vectors are column vectors. fp = fp(:); A = A(:); offset = offset(:); % Check the lenght of the input arguments. Larg = [length(fp); length(A); length(offset)]; K = max(Larg); if any((Larg ~= 1) & (Larg < K)) error('Vector valued input arguments must have same dimension.') end if (Larg(1) == 1) fp = fp*ones(K,1); end if (Larg(2) == 1) A = A*ones(K,1); end if (Larg(3) == 1) offset = offset*ones(K,1); end % Generate the sequence. x = A'*sawtooth(2*pi*fp*(0:N-1) + 2*pi*offset/100*ones(1,N),width/100); %----------------------------------------------------------------------- % End of function trisig %-----------------------------------------------------------------------