# ambgfun

Ambiguity and crossambiguity function

## Syntax

afmag = ambgfun(x,Fs,PRF)
afmag = ambgfun(x,y,Fs,PRF)
[afmag,delay,doppler] = ambgfun(___)
[afmag,delay,doppler] = ambgfun(___,"Cut","2D")
[afmag,delay] = ambgfun(___,"Cut","Doppler")
[afmag,delay] = ambgfun(___,"Cut","Doppler","CutValue",V)
[afmag,doppler] = ambgfun(___,"Cut","Delay")
[afmag,doppler] = ambgfun(___,"Cut","Delay","CutValue",V)
ambgfun(___)

## Description

example

afmag = ambgfun(x,Fs,PRF) returns the magnitude of the normalized ambiguity function for the vector x. Fs is the sampling rate. PRF is the pulse repetition rate.
afmag = ambgfun(x,y,Fs,PRF) returns the magnitude of the normalized crossambiguity function between the pulse x and the pulse y.

example

[afmag,delay,doppler] = ambgfun(___) or [afmag,delay,doppler] = ambgfun(___,"Cut","2D") returns the time delay vector, delay, and the Doppler frequency vector, doppler.

example

[afmag,delay] = ambgfun(___,"Cut","Doppler") returns delays from a zero-Doppler cut through the 2-D normalized ambiguity function magnitude.

example

[afmag,delay] = ambgfun(___,"Cut","Doppler","CutValue",V) returns delays from a nonzero Doppler cut through the 2-D normalized ambiguity function magnitude at Doppler value, V.
[afmag,doppler] = ambgfun(___,"Cut","Delay") returns the Doppler values from zero-delay cut through the 2-D normalized ambiguity function magnitude.
[afmag,doppler] = ambgfun(___,"Cut","Delay","CutValue",V) returns the Doppler values from a one-dimensional cut through the 2-D normalized ambiguity function magnitude at a delay value of V.

example

ambgfun(___), with no output arguments, plots the ambiguity or crossambiguity function. When "Cut" is "2D", the function produces a contour plot of the periodic ambiguity function. When "Cut" is "Delay" or "Doppler", the function produces a line plot of the periodic ambiguity function cut.

## Examples

collapse all

Plot the ambiguity function magnitude of a rectangular pulse.

waveform = phased.RectangularWaveform; x = waveform(); PRF = waveform.PRF; [afmag,delay,doppler] = ambgfun(x,waveform.SampleRate,PRF); contour(delay,doppler,afmag) xlabel("Delay (seconds)") ylabel("Doppler Shift (hertz)") Use the ambgfun function with no output arguments to recreate the plot.

ambgfun(x,waveform.SampleRate,PRF) This example shows how to plot zero-Doppler cuts of the autocorrelation sequences of rectangular and linear FM pulses of equal duration. Note the pulse compression exhibited in the autocorrelation sequence of the linear FM pulse.

hrect = phased.RectangularWaveform("PRF",2e4); hfm = phased.LinearFMWaveform("PRF",2e4); xrect = hrect(); xfm = hfm(); [ambrect,delayrect] = ambgfun(xrect,hrect.SampleRate,..., hrect.PRF,"Cut","Doppler"); [ambfm,delayfm] = ambgfun(xfm,hfm.SampleRate,..., hfm.PRF,"Cut","Doppler"); subplot(2,1,1) stem(delayrect,ambrect) title("Autocorrelation of Rectangular Pulse") subplot(2,1,2) stem(delayfm,ambfm) xlabel("Delay (seconds)") title("Autocorrelation of Linear FM Pulse") Plot nonzero-Doppler cuts of the autocorrelation sequences of rectangular and linear FM pulses of equal duration. Both cuts are taken at a 5 kHz Doppler shift. Besides the reduction of the peak value, there is a strong shift in the position of the linear FM peak, evidence of range-doppler coupling.

hrect = phased.RectangularWaveform("PRF",2e4); hfm = phased.LinearFMWaveform("PRF",2e4); xrect = hrect(); xfm = hfm(); fd = 5000; [ambrect,delayrect] = ambgfun(xrect,hrect.SampleRate,..., hrect.PRF,"Cut","Doppler","CutValue",fd); [ambfm,delayfm] = ambgfun(xfm,hfm.SampleRate,..., hfm.PRF,"Cut","Doppler","CutValue",fd); figure subplot(2,1,1) stem(delayrect*10^6,ambrect) title("Autocorrelation of Rectangular Pulse at 5 kHz Doppler Shift") subplot(2,1,2) stem(delayfm*10^6,ambfm) xlabel("Delay (\mu sec)") title("Autocorrelation of Linear FM Pulse at 5 kHz Doppler Shift") Plot the crossambiguity function between an LFM pulse and a delayed replica. Compare the crossambiguity function with the original ambiguity function. Set the sampling rate to 100 Hz, the pulse width to 0.5 sec, and the pulse repetition frequency to 1 Hz. The delay or lag is 10 samples equal to 100 ms. The bandwidth of the LFM signal is 10 Hz.

fs = 100.0; bw1 = 10.0; prf = 1; nsamp = fs/prf; pw = 0.5; nlag = 10;

Create the original waveform and its delayed replica.

waveform1 = phased.LinearFMWaveform("SampleRate",fs,"PulseWidth",1,... "SweepBandwidth",bw1,"SweepDirection","Up","PulseWidth",pw,"PRF",prf); wav1 = waveform1(); wav2 = [zeros(nlag,1);wav1(1:(end-nlag))];

Plot the ambiguity and crossambiguity functions.

ambgfun(wav1,fs,prf,"Cut","Doppler","CutVal",5) hold on ambgfun(wav1,wav2,fs,[prf,prf],"Cut","Doppler","CutVal",5) hold off legend("Signal ambiguity","Crossambiguity") ## Input Arguments

collapse all

Input pulse waveform, specified as a complex-valued row or column vector.

Example: wf = phased.LinearFMWaveform; wf()

Second input pulse waveform, specified as a complex-valued row or column vector.

Example: wf = phased.RectangularWaveform; wf()

Sample rate in hertz, specified as a positive scalar.

Example: wf = phased.LinearFMWaveform; wf.SampleRate

Data Types: double

Pulse repetition frequency in hertz, specified as a positive scalar.

Example: wf = phased.LinearFMWaveform; wf.PRF

Data Types: double

### Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: "Cut","Doppler","CutValue",10 specifies that a vector of ambiguity function values be produced at a Doppler shift of 10 Hz.

Used to generate an ambiguity surface or one-dimensional cut through the ambiguity diagram. The value "2D" generates a surface plot of the two-dimensional ambiguity function. The direction of the one-dimensional cut is determined by setting the value of "Cut" to "Delay" or "Doppler".

The choice of "Delay" generates a cut at zero time delay. In this case, the second output argument of ambgfuncontains the ambiguity function values at Doppler shifted values. You can create a cut at nonzero time delay using the name-value pair "CutValue".

The choice of "Doppler" generates a cut at zero Doppler shift. In this case, the second output argument of ambgfun contains the ambiguity function values at time-delayed values. You can create cut at nonzero Doppler using the name-value pair "CutValue".

Data Types: char | string

When setting the name-value pair "Cut" to "Delay" or "Doppler", you can set "CutValue" to specify a cross-section that may not coincide with either zero time delay or zero Doppler shift. However, "CutValue" cannot be used when "Cut" is set to "2D".

When "Cut" is set to "Delay" ,"CutValue" is the time delay at which the cut is taken. Time delay units are in seconds.

When "Cut" is set to "Doppler", "CutValue" is the Doppler shift at which the cut is taken. Doppler units are in hertz.

Example: "CutValue",10.0

Data Types: double

## Output Arguments

collapse all

Normalized ambiguity or crossambiguity function magnitudes, returned as a matrix. afmag is an M-by-N matrix where M is the number of Doppler frequencies and N is the number of time delays.

Time delays, returned as a vector. delay is an N-by-1 vector of time delays.

For the ambiguity function, if Nx is the length of signal x, then the delay vector consist of N = 2Nx – 1 samples in the range, –(Nx/2) – 1,...,(Nx/2) – 1).

For the crossambiguity function, let Ny be the length of the second signal. The time delay vector consists of N = Nx+ Ny– 1 equally spaced samples. For an even number of delays, the delay sample times are –(N/2 – 1)/Fs,...,(N/2 – 1))/Fs. For an odd number of delays, if Nf = floor(N/2), the delay sample times are –Nf /Fs,...,(Nf – 1)/Fs.

Doppler frequencies, returned as a vector. doppler is an M-by-1 vector of Doppler frequencies. The Doppler frequency vector consists of M = 2ceil(log2 N) equally-spaced samples. Frequencies are (–(M/2)Fs,...,(M/2–1)Fs).

collapse all

### Normalized Ambiguity Function

The normalized ambiguity function is

$\begin{array}{l}A\left(t,{f}_{d}\right)=\frac{1}{{E}_{x}}|{\int }_{-\infty }^{\infty }x\left(u\right){e}^{j2\pi {f}_{d}u}{x}^{*}\left(u-t\right)\text{ }\text{ }du|\text{ }\\ {E}_{x}={\int }_{-\infty }^{\infty }x\left(u\right){x}^{*}\left(u\right)\text{ }\text{ }du\end{array}$

where Ex is the squared norm of the signal, x(t), t is the time delay, and fd is the Doppler shift. The asterisk (*) denotes the complex conjugate. The ambiguity function describes the effects of time delays and Doppler shifts on the output of a matched filter.

The magnitude of the ambiguity function achieves maximum value at (0,0). At this point, there is perfect correspondence between the received waveform and the matched filter. The maximum value of the normalized ambiguity function is one.

The magnitude of the ambiguity function at zero time delay and Doppler shift, $|A\left(0,0\right)|,$ is the matched filter output when the received waveform exhibits the time delay and Doppler shift for which the matched filter is designed. Nonzero values of the time delay and Doppler shift variables indicate that the received waveform exhibits mismatches in time delay and Doppler shift from the matched filter.

The crossambiguity function between two different signals is

$\begin{array}{l}A\left(t,{f}_{d}\right)=\frac{1}{\sqrt{{E}_{x}{E}_{y}}}|{\int }_{-\infty }^{\infty }x\left(u\right){e}^{j2\pi {f}_{d}u}{y}^{*}\left(u-t\right)\text{ }\text{ }du|\text{ }\\ {E}_{x}={\int }_{-\infty }^{\infty }x\left(u\right){x}^{*}\left(u\right)\text{ }\text{ }du\\ {E}_{x}={\int }_{-\infty }^{\infty }y\left(u\right){y}^{*}\left(u\right)\text{ }\text{ }du\end{array}$

The peak of the crossambiguity function is not necessarily unity.

## Version History

Introduced in R2011a