
df=logspace(log10(.5),log10(1),20); f1=250+cumsum(df); f2=f1+df; 
df=logspace(log10(.5),log10(.75),40); f1=250+cumsum(df); f2=f1+df; %disp([f1;f2;df]'); 
df=logspace(log10(.5),log10(.75),60); f1=250+cumsum(df); f2=f1+df; %disp([f1;f2;df]'); 
df=logspace(log10(.5),log10(.75),60); f1=250+cumsum(df); f2=f1+df; %disp([f1;f2;df]'); 
df=logspace(log10(1),log10(2),50); f1=250+cumsum(df); f2=f1+df; %disp([f1;f2;df]'); 

f1=250; f2=280;
nline=length(f1); 
%shade=(8/3)*.5*(1 - cos([0:nline-1]*(2*pi)/(nline-1)));
shade=ones(nline,1);
Tw=20;

fmin=min([f1(:);f2(:)]); fmax=max([f1(:);f2(:)]);  BW=fmax-fmin; disp(sprintf('BW = %2.2f',BW));
fc=(fmin + fmax)/2; fs=1.5*(fmax - fmin);
npt=2.^nextpow2(Tw*fs), fs=npt/Tw; dt=1/fs;
t_ax=[0:npt-1]'*dt;
cts=zeros(size(t_ax));
f_t=zeros(length(t_ax),nline);

df_null=2; f_null=[fmin:df_null:fmax]; n_null=length(f_null);
df_null=logspace(log10(1),log10(2),50);
f_null=fmin + cumsum(df_null), n_null=length(f_null);
df_max=max(df_null),

for jline=1:nline,
        f_t(:,jline)=f1(jline) + t_ax*(f2(jline)-f1(jline))/Tw;         %LFM
        df=min(abs(repmat(f_t(:,jline),[1,n_null]) - repmat(f_null,[npt,1])),[],2); size(df),
        A_t=.5*(1 - cos((pi)*df./(df_max/2)));
        %f_t=fc + (f2-f1)*cos((2*pi/Tw)*t_ax);          %sinusoidal
        %slope=2*ones(size(t_ax)); slope(npt/2+1:npt)=-1; f_t=f1 + slope.*t_ax*(f2-f1)/Tw;%LFM up and down
        phase_t=2*pi*dt*cumsum(f_t(:,jline));
%       p=cos(phase_t);
        cts=cts + .5*shade(jline)*A_t.*exp(i*(phase_t - 2*pi*fc*t_ax));
end
figure(11); plot(t_ax,f_t);  pause; plot(t_ax,df); pause; plot(t_ax,A_t); pause;
keyboard
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.
