Main Content

phased.PhaseCodedWaveform

Phase-coded pulse waveform

Description

The phased.PhaseCodedWaveform System object™ creates a phase coded waveform. To create and use a phased.PhaseCodedWaveform System object

  1. Create the phased.PhaseCodedWaveform object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?

Creation

Description

waveform = phased.PhaseCodedWaveform() creates a phase-coded pulse waveform System object, waveform. The object generates samples of a phase-coded pulse.

waveform = phased.PhaseCodedWaveform(Name=Value) creates a phase-coded pulse waveform object, waveform, with additional options specified by one or more Name=Value pair arguments. Name is a property name, and Value is the corresponding value. You can specify several name-value pair arguments in any order as Name=Value1,…,NameN=ValueN.

example

Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

Sample rate, specified as a positive scalar. The value of this property must satisfy these constraints:

  • (SampleRate./PRF) is a scalar or vector that contains only integers — the number of samples in a pulse must be an integer.

  • (SampleRate*ChipWidth) is an integer value — the number of samples in a chip must be an integer.

Example: SampleRate=100e6

Data Types: double

Phase code type used in phase modulation, specified as:

  • "Frank"

  • "P1"

  • "P2"

  • "Px"

  • "Zadoff-Chu"

  • "P3"

  • "P4"

  • "Barker"

  • "Maximum Length Sequence"

  • "Quadratic Residue Sequence"

  • "Custom"

Example: Code="Quadratic Residue Sequence"

Data Types: char | string

Custom phase code, specified as a length-M vector of complex values. Each element in the specified vector corresponds to a single chip. You can use these functions and others to create custom phase code:

Custom Code Functions

  
apaseqPseudo-random binary almost perfect autocorrelation sequence
legendreseqLegendre sequence with a perfect periodic autocorrelation
mlseqPseudo-random binary maximum length sequence
pnkcodePolyphase code

Example: CustomCode=mlseq

Dependencies

To enable this property, set the Code property to "Custom".

Data Types: double | function_handle

The time duration of each chip in a phase-coded waveform, specified as a positive scalar. For this waveform, the pulse duration is equal to the product of the chip width and number of chips.

The value of this property must satisfy these constraints:

  • ChipWidth is less than or equal to (1./(NumChips*PRF)) – the total time duration of all chips cannot exceed the duration of the pulse.

  • (SampleRate*ChipWidth) is an integer value – the number of samples in a chip must be an integer.

Units are in seconds.

Example: Chipwidth=40e-5

Data Types: double

Number of chips per pulse in a phase-coded waveform, specified as a positive integer. The value of this property must be less than or equal to (1./(ChipWidth*PRF)) – the total time duration of all chips cannot exceed the pulse repetition interval.

This table shows additional constraints on the number of chips for different code types.

If the Code property is ...Then the NumChips property must be...
"Frank", "P1", or "Px"A perfect square
"P2"An even number that is a perfect square
"Barker"2, 3, 4, 5, 7, 11, or 13

Dependencies

To enable this property, set the Code property to any value except "Custom".

Data Types: double

Sequence index used in Zadoff-Chu code, specified as a positive integer. The value of SequenceIndex must be relatively prime to the value of the NumChips property.

Example: SequenceIndex

Dependencies

To enable this property, set the Code property to "Zadoff-Chu".

Data Types: double

Pulse repetition frequency (PRF), specified as a scalar or a row vector. Units are in Hz. The pulse repetition interval (PRI) is the inverse of the pulse repetition frequency PRF value. The PRF must satisfy these restrictions:

  • The product of PRF and PulseWidth must be less than or equal to one. This condition requires that the pulse width is less than one PRI. For the phase-coded waveform, the pulse width is the product of the values of the ChipWidth and NumChips properties.

  • The ratio of SampleRate to PRF must be an integer. This condition requires that the number of samples in one PRI is an integer.

You can set the value of PRF using the PRF property settings alone or using property settings in conjunction with the prfidx input argument of the object.

  • When PRFSelectionInputPort is false, you set the PRF using the PRF properties alone. You can:

    • Implement a constant PRF by specifying the PRF property as a positive real-valued scalar.

    • Implement a staggered PRF by specifying the PRF property as a row vector with positive real-valued elements. Each call to the object uses successive elements of this vector as the PRF. Once the object reaches the last element of the vector, it continues the process cyclically with the first element of the vector.

  • When PRFSelectionInputPort is true, you can set the PRF value using the PRF property in conjunction with the prfidx input argument. You implement a selectable PRF by specifying the PRF property as a row vector with positive real-valued elements. When you execute the object, the object selects a PRF by using the index you specify in the prfidx input argument to index into the PRF vector.

In all cases, the number of output samples is fixed when you set the OutputFormat property to 'Samples'. When you use a varying PRF and also set the OutputFormat property to 'Pulses', the number of samples can vary.

Data Types: double

Enable PRF selection input, specified as false or true. When you set this property to true, you can pass an index argument to the object to select a predefined value from the PRF property vector. When you set this property to false, the object uses the PRF property to define the PRF sequence used in the simulation.

Data Types: logical

Source of frequency offset, specified as 'Property' or 'Input port'.

  • When you set this property to 'Property', the frequency offset is determined by the value of the FrequencyOffset property.

  • When you set this property to 'Input port', the frequency offset is determined by the input argument freqoffset when calling the object.

Example: 'Input port'

Data Types: char | string

Frequency offset, specified as a scalar. Units are in Hz.

Example: 150.0

Dependencies

To enable this property, set the FrequencyOffsetSource property to 'Property'.

Data Types: double

Format of output signal, specified as 'Pulses' or 'Samples'.

  • When you set the OutputFormat property to 'Pulses', the output of the object takes the form of multiple pulses specified by the value of the NumPulses property. The number of samples per pulse can vary if you change the PRF during the simulation.

  • When you set the OutputFormat property to 'Samples', the output of the object takes the form of multiple samples. In this case, the number of output signal samples is the value of the NumSamples property and is fixed.

Data Types: char | string

Number of samples in each output of the object, specified as a positive integer.

Dependencies

To enable this property, set the OutputFormat property to 'Samples'.

Data Types: double

Number of pulses in each output, specified as a positive integer.

Dependencies

To enable this property, set the OutputFormat property to 'Pulses'.

Data Types: double

Enable PRF output, specified as false or true. Set this property to true to output the PRF.

Dependencies

To enable this property, set the OutputFormat property to 'Pulses'.

Data Types: logical

Enable matched filter coefficients output, specified as false or true. Set this property to true to enable the object the output of the matched filter coefficients of the waveform used during the simulation.

Data Types: logical

Usage

Description

Y = waveform() returns samplesY of the phase-coded pulse, .

Y = waveform(prfidx) uses the prfidx index to select the PRF from the predefined vector of values specified by the PRF property. To enable this syntax, set the PRFSelectionInputPort property to true.

Y = waveform(freqoffset) uses freqoffset to generate the waveform with a frequency offset. Use this syntax for cases where the transmit pulse frequency needs to be dynamically updated. To enable this syntax applies, set the FrequencyOffsetSource property to "Input port".

example

[Y,PRF] = waveform(___) also returns the current pulse repetition frequency, PRF. To enable this syntax, set the PRFOutputPort property to true and set the OutputFormat property to "Pulses".

[Y,coeff] = waveform(___) returns the matched filter coefficients, coeff, for the current pulse. To enable this syntax, set CoefficientsOutputPort property to true.

You can combine optional input and output arguments when their enabling properties are set. Optional inputs and outputs must be listed in the same order as the order of the enabling properties. For example, Y,PRF,COEFF] = waveform(prfidx,freqoffset).

Note

The object performs an initialization the first time the object is executed. This initialization locks nontunable properties and input specifications, such as dimensions, complexity, and data type of the input data. If you change a nontunable property or an input specification, the System object issues an error. To change nontunable properties or inputs, you must first call the release method to unlock the object.

Input Arguments

expand all

Pulse repetition frequency (PRF) index, specified as a positive integer. The index identifies which entry in the PRF property is used to determine the PRF. Use this argument when the transmit pulse needs to be dynamically selected. Under such situations, the PRF property includes a list of predetermined choices of PRFs. prfidx selects the PRF for the next transmission.

Example: 10

Dependencies

To enable this argument, set the PRFSelectionInputPort property to true.

Data Types: double

Frequency offset, specified as a scalar. The offset adds a frequency offset to the generated waveform. Units are in Hz.

Example: 50.0

Dependencies

To enable this argument, set the FrequencyOffsetSource property to Input port.

Output Arguments

expand all

Phase-coded waveform, returned as a complex-valued column vector.

Data Types: single | double
Complex Number Support: Yes

Matched filter coefficients, returned as an Nz-by-1 vector, where Nz is the largest nonzero pulse width.

Dependencies

To enable this output, set the CoefficientsOutputPort property to true.

Data Types: single | double
Complex Number Support: Yes

Current pulse repetition frequency, returned as a positive scalar.

Example: 250

Dependencies

To enable this output argument, set the OutputFormat property to "Pulses" and the PRFOutputPort property to true.

Data Types: single | double

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)

expand all

bandwidthBandwidth of phase-coded waveform
getMatchedFilterMatched filter coefficients for waveform
plotPlot phase-coded pulse waveform
stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

collapse all

Generate samples of two pulses of a phase-coded pulse waveform that uses the Zadoff-Chu code.

sPCW = phased.PhaseCodedWaveform('Code','Zadoff-Chu',...
    'ChipWidth',1e-6,'NumChips',16,...
    'OutputFormat','Pulses','NumPulses',2);
wav = step(sPCW);
fs = sPCW.SampleRate;
nsamps = size(wav,1);
t = [0:(nsamps-1)]/fs;
plot(t*1e6,real(wav))
title('Waveform: Real Part')
xlabel('Time (\mu sec)')
ylabel('Amplitude')
grid

Figure contains an axes object. The axes object with title Waveform: Real Part, xlabel Time ( mu blank sec), ylabel Amplitude contains an object of type line.

Create and plot a two-pulse phase-coded waveform that uses the Zadoff-Chu code.

sPCW = phased.PhaseCodedWaveform('Code','Zadoff-Chu',...
    'ChipWidth',5e-6,'NumChips',16,...
    'OutputFormat','Pulses','NumPulses',2);
fs = sPCW.SampleRate;

Generate signal samples and plot the magnitude and phase of the waveforms.

wav = step(sPCW);
nsamp = size(wav,1);
t = [0:(nsamp-1)]/fs;
plot(t*1e6,abs(wav),'.-')
title('Magnitude')
xlabel('Time (\mu sec)')
ylabel('Amplitude')

Figure contains an axes object. The axes object with title Magnitude, xlabel Time ( mu blank sec), ylabel Amplitude contains an object of type line.

plot(t*1e6,180/pi*angle(wav))
title('Phase Angle')
xlabel('Time (\mu sec)')
ylabel('Phase Angle (deg)')

Figure contains an axes object. The axes object with title Phase Angle, xlabel Time ( mu blank sec), ylabel Phase Angle (deg) contains an object of type line.

Plot the spectrum.

nsamp = size(wav,1);
nfft = 2^nextpow2(nsamp);
Z = fft(wav,nfft);
fr = [0:(nfft-1)]/nfft*fs;
fr = fr - fs/2;
plot(fr/1000,abs(fftshift(Z)))
xlabel('Frequency (kHz)')
ylabel('Amplitude')
grid

Figure contains an axes object. The axes object with xlabel Frequency (kHz), ylabel Amplitude contains an object of type line.

Apply a frequency offset to a phase-coded waveform that uses the Zadoff-Chu code. Plot the frequency spectrum of the waveform with and without a frequency offset applied.

Create a phase-coded waveform object which is configured to set the frequency offset from an input when the object is executed.

fs = 1e6;
sPCW = phased.PhaseCodedWaveform('SampleRate',fs,'Code','Zadoff-Chu', ...
    'ChipWidth',8e-6,'NumChips',4,'OutputFormat','Pulses', ...
    'NumPulses',1,'FrequencyOffsetSource','Input port');

Execute the object two times. First set the frequency offset set to 0 Hz, and then to 2e4 Hz.

pcwav = sPCW(0);
pcwav_foffset = sPCW(2e4);

Plot the frequency spectrum of the complex signals. The frequency offset signal is shifted to the right.

[Pxx,f] = pwelch(pcwav,[],[],[],fs,'centered');
[Pxx_offset,foffset] = pwelch(pcwav_foffset,[],[],[],fs,'centered');
plot(f/1000,Pxx,foffset/1000,Pxx_offset)
ylabel('PSD');
xlabel('Frequency (kHz)');
legend({'No offset','Offset applied'},'Location','northwest');
grid on;

Figure contains an axes object. The axes object with xlabel Frequency (kHz), ylabel PSD contains 2 objects of type line. These objects represent No offset, Offset applied.

Generate two phase-coded waveforms based on m-sequences of length N = 127. Show their ambiguity and crossambiguity functions. The chip width is 1μsec and the modulation period is N times the chip width.

N = 127;
S = mlseq(N,[1 2]);

Set the chip width (tau) and the modulation period (T).

tau = 1e-6; 
T = tau*N;

Create a custom phase coded waveform object. Set the pulse repetition frequency (PRF) equal to the inverse of the modulation period and set the sampling rate to 10 times the inverse chip width. Initialize the waveform with the first code.

fs = 10/tau;    % Sample rate
pmwaveform = phased.PhaseCodedWaveform('SampleRate',fs,'Code','Custom',...
    'CustomCode',S(:,1),'ChipWidth',tau,'PRF',1/T);

Generate samples of the first waveform.

x1 = pmwaveform();

Generate samples of the second waveform.

release(pmwaveform);
pmwaveform.CustomCode = S(:,2);
x2 = pmwaveform();

Plot the ambiguity and cross-ambiguity functions.

tiledlayout(3, 1)

nexttile
ambgfun(x1,fs,1/T,'Cut','Doppler');
title('Ambiguity Function of the First Waveform')

nexttile
ambgfun(x2,fs,1/T,'Cut','Doppler');
title('Ambiguity Function of the Second Waveform')

nexttile
ambgfun(x1,x2,fs,[1 1]/T,'Cut','Doppler');
title('Cross Ambiguity Function')

Figure contains 3 axes objects. Axes object 1 with title Ambiguity Function of the First Waveform, xlabel Delay {\tau} (µs), ylabel Ambiguity Function contains an object of type line. Axes object 2 with title Ambiguity Function of the Second Waveform, xlabel Delay {\tau} (µs), ylabel Ambiguity Function contains an object of type line. Axes object 3 with title Cross Ambiguity Function, xlabel Delay {\tau} (µs), ylabel Crossambiguity Function contains an object of type line.

Create and plot two-pulse phase-coded waveforms that uses the Zadoff-Chu code. Set the sample rate to 1 MHz, a chip width of 5 microseconds, 16 chips per pulse. Vary the pulse repetition frequency.

fs = 1e6;
PRF = [5000,10000];
waveform = phased.PhaseCodedWaveform('SampleRate',fs,...
    'Code','Zadoff-Chu','PRFSelectionInputPort',true,...
    'ChipWidth',5e-6,'NumChips',16,'PRF',PRF,...
    'OutputFormat','Pulses','NumPulses',2);

Obtain and plot the phase-coded waveforms. For the first call to the step method, set the PRF to 10kHz using the PRF index. For the next call, set the PRF to 25 kHz. For the final call, set the PRF to 10kHz.

wav = [];
wav1 = waveform(1);
wav = [wav; wav1];
wav1 = waveform(2);
wav = [wav; wav1];
wav1 = waveform(1);
wav = [wav; wav1];
nsamps = size(wav,1);
t = [0:(nsamps-1)]/fs;
plot(t*1e6,real(wav))
xlabel('Time (\mu sec)')
ylabel('Amplitude')

Figure contains an axes object. The axes object with xlabel Time ( mu blank sec), ylabel Amplitude contains an object of type line.

Generate output samples and matched filter coefficients of a Barker coded waveform.

waveform = phased.PhaseCodedWaveform('Code','Barker','NumChips',5, ...
    'CoefficientsOutputPort',true,'PRF',[1e4 2e4],'ChipWidth',5e-6, ...
    'OutputFormat','Samples','NumSamples',150);
[wav,coeff] = waveform();

Create a matched filter that applies the coefficients as an input argument. Use the coefficients when applying the matched filter to the waveform. Plot the waveform and matched filter outputs.

mf = phased.MatchedFilter('CoefficientsSource','Input port');
mfOut = mf(wav,coeff);
subplot(211),plot(real(wav));
xlabel('Samples'),ylabel('Amplitude'),title('Waveform Output');
subplot(212),plot(abs(mfOut));
xlabel('Samples'),ylabel('Amplitude'),title('Matched Filter Output');

Figure contains 2 axes objects. Axes object 1 with title Waveform Output, xlabel Samples, ylabel Amplitude contains an object of type line. Axes object 2 with title Matched Filter Output, xlabel Samples, ylabel Amplitude contains an object of type line.

Algorithms

A 2-chip Barker code can use [1 –1] or [1 1] as the sequence of amplitudes. This software implements [1 –1].

A 4-chip Barker code can use [1 1 –1 1] or [1 1 1 –1] as the sequence of amplitudes. This software implements [1 1 –1 1].

A Zadoff-Chu code can use a clockwise or counterclockwise sequence of phases. This software implements the latter, such as πf(k)SequenceIndex/NumChips instead of πf(k)SequenceIndex/NumChips. In these expressions, k is the index of the chip and f(k) is a function of k.

For further details, see [1].

References

[1] Levanon, N. and E. Mozeson. Radar Signals. Hoboken, NJ: John Wiley & Sons, 2004.

Extended Capabilities

expand all

Version History

Introduced in R2011b

expand all