function varargout = dspblkchirp2(action,varargin)
% DSPBLKCHIRP2 DSP Blockset CHIRP block helper function.

% Copyright 1995-2000 The MathWorks, Inc.
% $Revision: 1.5 $ $Date: 2000/06/07 16:50:18 $

blk = gcbh;

switch action,
case 'icon'
	t = [0:0.1:1.5*pi];
	y = (sin(t.*t)+1)/2*0.7;
	t = t / max(t);
   
    % Determine string on icon:
    txt = get_param(blk,'sweep');
    switch txt
    case {'Quadratic'}
        txt=txt(1:4); 
    case {'Linear', 'Logarithmic'}
        txt=txt(1:3); 
    case {'Swept cosine'}
        txt=txt(1:5); 
    end
    
   varargout = {t,y,txt};
   
case 'param'
   sweep = varargin{1};
   f0    = varargin{2};
   f1    = varargin{3};
   t1    = varargin{4};
      
   % Error checking:
	if (sweep == 3) & (f0 > f1),
   	error('F1>F0 is required for a log-sweep.');
	end
      
    fd = abs(f1-f0);
        
    switch sweep
    case 1
        % Swept cosine
        beta = fd/t1;
    case 3
        % Logarithmic
        beta = log10(fd)./t1;
    otherwise
        % Linear and Quadratic
        beta = fd.*(t1.^(-sweep));
    end
    
   varargout = {beta};   
end


