f1=[250; 280]; f2=[280; 250]; Tw=[10,10]; % Uniform 25 dB down; X w/ +-.2/.1 slopes
f1=[250; 310]; f2=[310; 250]; Tw=[10,10]; % Almost-uniform 27 dB down; X w/ +-.2/.05 slopes
f1=[250; 280; 250; 280]; f2=[280; 250; 280; 250];
% 25-dB uniform SL, but repeat at tau=10s;
%f1=[250*ones(1,10); 280*ones(1,10)]; f1=f1(:); f2=[f1(2:end); f1(1)];
%Tw=1*ones(1,20);
% Ugly: 2-s periods.
%f1=[250; 265; 265]; f2=[265; 265; 280]; [nseg,nline]=size(f1), Tw=20/nseg*ones(1,nseg);
% Bad inside tau band inside 20/3; only gets good after 6.667 s
%f1=[250; 280]; f2=[280; 280]; 
%[nseg,nline]=size(f1);
%Tw=20/nseg*ones(1,nseg); 
% Bad: Big blob in alpha shape only 5 dB down or so;
%f1=[250; 280; 280; 250]; f2=[280; 280; 250; 250]; 
%
f1=linspace(250,280,20); f2=f1; 

[nseg,nline]=size(f1),
Tw=20/nseg*ones(1,nseg); 
Tw_tot=sum(Tw), Tw_cum=[0;cumsum(Tw(:));1000];

fmin=min([f1(:);f2(:)]); fmax=max([f1(:);f2(:)]);
fc=(fmin + fmax)/2; fs=1.5*(fmax - fmin);
npt=2.^nextpow2(Tw_tot*fs); fs=npt/Tw_tot; dt=1/fs;
t_ax=[0:npt-1]'*dt;
cts=zeros(size(t_ax));
f_t=zeros(length(t_ax),nline);
for jseg=1:nseg,
        ii=find(t_ax>=Tw_cum(jseg) & t_ax<=Tw_cum(jseg+1)); t0=Tw_cum(jseg);
        for jline=1:nline,
                f_t(ii,jline)=f1(jseg,jline) + (t_ax(ii)-t0)*(f2(jseg,jline)-f1(jseg,jline))/Tw(jseg);
                phase_t=2*pi*dt*cumsum(f_t(ii,jline));
        %       p=cos(phase_t);
                cts(ii)=cts(ii) + .5*exp(i*(phase_t - 2*pi*fc*t_ax(ii)));
        end
end
figure(11); plot(t_ax,f_t);  pause;

nd=81; dmax=0.1; iihann=1; nzp_tau=1;
%nd=3; dmax=0.2; iihann=1; nzp_tau=1;
nd=0; dmax=0; iihann=1; nzp_tau=1;
AS.title='Ambiguity Surface';
[AS.x,AS.y,AS.data]=ambi_surf(fs,f_bb,cts,nd,dmax,iihann,nzp_tau);

figure(10);
AS.xlab='Delay'; AS.ylab='D';AS.dlab='Ambiguity - dB';
AS.iidB=1;
Amax=ceil(max(AS.data(:))/5)*5; AS.clim=[Amax-70,Amax];
figure(10); iinewfig=0;
view5(AS,[],[],0);
%
% COPYRIGHT (c) 2008
% 
% Applied Research Laboratories, The University of Texas at Austin
% (ARL:UT)
% All rights reserved.
% 
% This material may be reproduced by or for the U.S. Government
% only. This notice must appear in all copies of this file and its
% derivatives. Further distribution outside the U.S. Government is
% prohibited without the explicit written authorization from the
% Director of the Environmental Sciences Laboratory, ARL:UT.
% 
% THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
% EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE
% IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
% PURPOSE, OR NONINFRINGEMENT.
% 
% IN NO EVENT WILL ARL:UT BE LIABLE FOR ANY DAMAGES WHATSOEVER ARISING
% OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN IF ARL:UT HAS
% BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
