Main Content

phased.RectangularWaveform

Rectangular pulse waveform

Description

To create and use a phased.RectangularWaveform waveforms

  1. Create the phased.RectangularWaveform 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.RectangularWaveform creates a phased.RectangularWaveform System object™, waveform, with default property values.

example

waveform = phased.RectanbularWaveform(Name=Value) creates a rectangular waveform System object with each specified property Name set to the specified Value. You can specify additional name-value pair arguments in any order as (Name1=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.

Signal sample rate, specified as a positive scalar. The ratio of sample rate to pulse repetition frequency must be a positive integer, so the number of samples in each pulse must be an integer value. Units are in Hertz.

Example: 100e3

Data Types: double

Method to set pulse duration (pulse width), specified as 'Pulse width' or 'Duty cycle'. This property determines how you set the pulse duration.

  • When you set this property to 'Pulse width', set the pulse duration directly using the PulseWidth property.

  • When you set this property to 'Duty cycle', set the pulse duration from the values of the PRF and DutyCycle properties. The pulse width is equal to the value of the DutyCycle property divided by the value of the PRF property.

Data Types: char | string

Pulse time duration, specified as a positive scalar. The value must satisfy PulseWidth <= 1./PRF. Units are in seconds.

Dependencies

To enable this property, set the DurationSpecification property to 'Pulse width'.

Data Types: double

Pulse duty cycle, specified as a positive scalar in the range [0,1]. The pulse width is the value of the DutyCycle property divided by the value of the PRF property. This quantity is dimensionless.

Example: 0.75

Dependencies

To enable this property, set the DurationSpecification property to 'Duty cycle'.

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 a rectangular pulse waveform Y.

Y = waveform(prfidx) uses the prfidx index to select a pulse repetition frequency (PRF) from the predefined vector of values specified by the PRF property. This syntax applies when you set the PRFSelectionInputPort property to true

example

Y = waveform(freqoffset), uses the freqoffset to generate the waveform with an offset as specified at step time. Use this syntax for cases where the transmit pulse frequency needs to be dynamically updated. This syntax applies when you set the FrequencyOffsetSource property to 'Input port'.

[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'. PRF returns the current pulse repetition frequency used by the system.

[Y,COEFF] = waveform(___) also returns the matched filter coefficients, COEFF, for the current pulse. To enable this syntax, set CoefficientsOutputPort 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).

Input Arguments

expand all

Index of pulse repetition frequency (PRF), specified as a positive integer. The index identifies entries in the PRF property. Use this argument for the cases where the transmit pulse needs to be dynamically selected. Such situations, the PRF property contains a list of predetermined choices of PRFs. During the simulation, based on prfidx input, one of the PRFs is selected as the PRF for the next transmission.

Dependencies

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

Frequency offset, specified as a scalar. The offset lets you generate the waveform with a frequency offset. Use this argument for the cases where the transmit pulse frequency needs to be dynamically updated.

Example: -1100.0

Dependencies

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

Data Types: double

Output Arguments

expand all

Waveform samples, returned as complex-valued column vector.

Data Types: double

Pulse repetition frequency, returned as a scalar. PRF contains the current PRF used by the system.

Dependencies

To enable this argument, you set the PRFOutputPort property to true and the OutputFormat property to 'Pulses'.

Data Types: double

Matched filter coefficients, returned as a NZ-by-1 complex-valued vector or a NZ-by-M complex-valued matrix.

  • If the OutputFormat property is set to 'Pulses' and the NumPulses property is set to 1, COEFF is returned as an NZ-by-1 complex-valued vector. NZ corresponds to the pulse width.

  • If the OutputFormat property is set to 'Pulses' and the NumPulses property greater than 1 or the OutputFormat property is set to 'Samples' and the DurationSpecification property is set to 'Pulse width', COEFF is returned as an NZ-by-1 complex-valued vector. NZ corresponds to the pulse width.

  • If the OutputFormat property is set to 'Pulses' and the NumPulses property greater than 1 or if the OutputFormat property is set to 'Samples' and the DurationSpecification property is set to 'Duty cycle' with only one unique PRF value, COEFF is returned as an NZ-by-1 complex-valued vector. NZ corresponds to the pulse width.

  • If the OutputFormat property is set to 'Pulses' with NumPulses property greater than 1 or if the OutputFormat property is set to 'Samples' and the DurationSpecification property is set to 'Duty cycle' with more than one unique PRF value, COEFF is returned as an NZ-by-M matrix. NZ corresponds to the maximum pulse width and M corresponds to the number of unique PRFs.

Data Types: double
Complex Number Support: Yes

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 rectangular pulse waveform
getMatchedFilterMatched filter coefficients for waveform
plotPlot rectangular 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

Construct a 10 microseconds rectangular pulse with a pulse repetition interval of 100 microseconds.

Pulsewidth = 10e-6;
PRI = 100e-6;
sRFM = phased.RectangularWaveform('PulseWidth',Pulsewidth,...
    'OutputFormat','Pulses','NumPulses',1,...
    'SampleRate',1e6,'PRF',1/PRI);
wav = step(sRFM);
plot(wav)
xlabel('Time (\mu sec)')
ylabel('Amplitude')
grid

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

Construct rectangular waveforms with two pulses each. Set the sample rate to 1 MHz, a pulse width of 50 microseconds, and a duty cycle of 20%. Vary the pulse repetition frequency.

Set the sample rate and PRF. The ratio of sample rate to PRF must be an integer.

fs = 1e6;
PRF = [10000,25000];
waveform = phased.RectangularWaveform('OutputFormat','Pulses','SampleRate',fs,...
    'DurationSpecification','Duty Cycle','DutyCycle',.2,...
    'PRF',PRF,'NumPulses',2,'PRFSelectionInputPort',true);

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

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)]/waveform.SampleRate;
plot(t*1e6,real(wav))
xlabel('Time (\mu sec)')
ylabel('Amplitude')
grid

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

Create and plot a rectangular pulse waveform object and then plot its spectrum.

Plot the waveform

Create and plot a pulse waveform. The sample rate is 500 kHz, the pulse width is 0.1 millisecond. The pulse repetition interval is twice the pulse duration.

fs = 500e3;

Create the rectangular waveform System object™.

sWF = phased.RectangularWaveform('SampleRate',fs,'PulseWidth',1e-4,'PRF',5000.0);

Use the step method to obtain the waveform. Then, plot the waveform.

rectwav = step(sWF);
nsamp = size(rectwav,1);
t = [0:(nsamp-1)]/fs;
plot(t*1000,real(rectwav))
xlabel('Time (millisec)')
ylabel('Amplitude')
grid

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

Plot the spectrum

Compute the Fourier transform of the complex signal. Then show the spectrum.

nfft = 2^nextpow2(nsamp);
Z = fft(real(rectwav),nfft);
fr = [0:(nfft/2-1)]/nfft*fs;
plot(fr/1000,abs(Z(1:nfft/2)),'.-')
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.

Plot the spectrogram

Plot a spectrogram of the function with a window size of 64 samples and 50% overlap. Window the signal with a Hamming function.

nfft1 = 64;
nov = floor(0.5*nfft1);
spectrogram(rectwav,hamming(nfft1),nov,nfft1,fs,'centered','yaxis')

Figure contains an axes object. The axes object with xlabel Time (μs), ylabel Frequency (kHz) contains an object of type image.

This plot shows the constant frequency of the signal.

Apply a frequency offset to a rectangular pulse waveform. Plot the frequency spectrum of the waveform with and without a frequency offset applied.

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

fs = 500e3;
sRWF = phased.RectangularWaveform('SampleRate',fs,'PulseWidth',1e-4, ...
    'PRF',5000.0,'FrequencyOffsetSource','Input port');

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

rectwav = sRWF(0);
rectwav_foffset = sRWF(2e4);

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

[Pxx,f] = pwelch(rectwav,[],[],[],fs,'centered');
[Pxx_offset,foffset] = pwelch(rectwav_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 output samples and matched filter coefficients of a rectangular pulse waveform.

waveform = phased.RectangularWaveform('CoefficientsOutputPort',true, ...
    'PRF',[1e4 2e4],'DurationSpecification','Duty cycle','DutyCycle',0.5, ...
    'OutputFormat','Pulses','NumPulses',2,'PRFSelectionInputPort',true); 
[wav,coeff] = waveform(1);

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(:,1));
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.

References

[1] Richards, M. A. Fundamentals of Radar Signal Processing. New York: McGraw-Hill, 2005.

Extended Capabilities

Version History

Introduced in R2011a