Main Content

dsp.Chirp

Generate swept-frequency cosine (chirp) signal

Description

The dsp.Chirp System object™ generates a swept-frequency cosine (chirp) signal. The chirp function also generates a swept-frequency cosine (chirp) signal. However, the object can process large streams of real-time data and handle system states automatically. The function performs one-time computations on data that is readily available and cannot handle system states. For a comparison between the two, see System Objects vs MATLAB Functions.

To generate the chirp signal:

  1. Create the dsp.Chirp 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

chirp = dsp.Chirp returns a chirp signal, chirp, with unity amplitude.

chirp = dsp.Chirp(Name=Value) returns a chirp signal with each specified property set to the specified value.

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.

Specify the frequency sweep type as Swept cosine, Linear, Logarithmic, or Quadratic. This property specifies how the output instantaneous frequency sweep varies over time.

Specify the sweep direction as either Unidirectional or Bidirectional.

When you set the Type property to Linear, Quadratic, or Logarithmic, this property specifies the initial instantaneous frequency in hertz of the output chirp signal. When you set the Type property to Logarithmic, the value of this property is one less than the actual initial frequency of the sweep. Also, when the sweep is logarithmic, the initial frequency must be less than the target frequency, specified by the TargetFrequency property.

Tunable: Yes

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

When you set the Type property to Linear, Quadratic, or Logarithmic, this property specifies the instantaneous frequency of the output signal in hertz at the target time. When you set the Type property to Swept Cosine, the target frequency is the instantaneous frequency of the output at half the target time. Also, when the sweep is logarithmic, the target frequency must be greater than the initial frequency, specified by the InitialFrequency property.

Tunable: Yes

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

When you set the Type property to Linear, Quadratic, or Logarithmic, this property specifies the target time in seconds at which the target frequency is reached. When you set the Type property to Swept cosine, this property specifies the time at which the sweep reaches 2ftgt – finit Hz, where ftgt is the TargetFrequency and finit is the InitialFrequency. The target time should not be greater than the sweep time, specified by the SweepTime property.

Tunable: Yes

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

When you set the SweepDirection property to Unidirectional, the sweep time in seconds is the period of the output frequency sweep. When you set the SweepDirection property to Bidirectional, the sweep time is half the period of the output frequency sweep. The sweep time should be no less than the target time, specified by the TargetTime. This property must be a positive numeric scalar.

Tunable: Yes

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Specify initial phase of the output in radians at time t = 0.

Tunable: Yes

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Specify the sampling rate of the output in hertz as a positive numeric scalar.

Data Types: single | double | logical

Specify the number of samples to buffer into each output as a positive integer. The default value is 1.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Specify the output data type as double or single. The default value is double.

Usage

Description

y = chirp() returns a swept-frequency cosine output, y.

example

Output Arguments

expand all

Swept-frequency cosine output, returned as a scalar or a column vector. The length of the output vector equals the value you specify in the SamplesPerFrame property.

Data Types: 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

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 a bidirectional chirp signal with these settings:

  • Target frequency of 25 Hz

  • Initial frequency of 0 Hz

  • Sweep time of 1 second

  • Target time of 1 second

  • 400 samples per frame

  • Sample rate of 400 Hz

chirp = dsp.Chirp(...
    SweepDirection='Bidirectional', ...
    TargetFrequency=25, ...
    InitialFrequency=0,...
    TargetTime=1, ...
    SweepTime=1, ...
    SamplesPerFrame=400, ...
    SampleRate=400)
chirp = 
  dsp.Chirp with properties:

                Type: 'Linear'
      SweepDirection: 'Bidirectional'
    InitialFrequency: 0
     TargetFrequency: 25
          TargetTime: 1
           SweepTime: 1
        InitialPhase: 0
     SamplesPerFrame: 400
          SampleRate: 400
      OutputDataType: 'double'

Plot the chirp signal.

plot(chirp());

Figure contains an axes object. The axes object contains an object of type line.

Initialize the spectrumAnalyzer object to show the spectrogram.

specAna = spectrumAnalyzer(ViewType="spectrogram",...
    Method="welch",...
    FrequencyResolutionMethod="window-length",...
    WindowLength=128,...
    FFTLengthSource="auto",...
    SpectrumUnits="dBm",...
    TimeSpanSource="property",...
    TimeSpan=6,...
    FrequencySpan="start-and-stop-frequencies",...
    StartFrequency=0,...
    StopFrequency=40,...
    Window="hamming",...
    OverlapPercent=80,...
    SampleRate=400,...
    FrequencyOffset=0,...
    Colormap="parula",...
    AveragingMethod="exponential",...
    ForgettingFactor=0,...
    PlotAsTwoSidedSpectrum=true)
specAna = 
  spectrumAnalyzer handle with properties:

               InputDomain: 'time'
              SpectrumType: 'power'
                  ViewType: 'spectrogram'
                SampleRate: 400
                    Method: 'welch'
    PlotAsTwoSidedSpectrum: 1
            FrequencyScale: 'linear'
               AxesScaling: 'auto'

  Show all properties

Stream in the chirp signal and pass the data to the spectrum analyzer.

for i = 1:1000
    input = chirp();
    specAna(input);
end

Algorithms

This object implements the algorithm, inputs, and outputs described on the Chirp block reference page. The object properties correspond to the block parameters.

Version History

Introduced in R2012a

See Also

Functions

Objects