# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

# Chirp

Generate swept-frequency cosine (chirp) signal

## Library

Sources

`dspsrcs4`

## Description

The Chirp block outputs a swept-frequency cosine (chirp) signal with unity amplitude and continuous phase. To specify the desired output chirp signal, you must define its instantaneous frequency function, also known as the output frequency sweep. The frequency sweep can be linear, quadratic, or logarithmic, and repeats once every Sweep time by default. See other sections of this reference page for more details about the block.

### Sections of This Reference Page

Variables Used in This Reference Page

 f0 Initial frequency parameter (Hz) fi(tg) Target frequency parameter (Hz) tg Target time parameter (seconds) Tsw Sweep time parameter (seconds) ${\varphi }_{0}$ Initial phase parameter (radians) $\psi \left(t\right)$ Phase of the chirp signal (radians) fi(t) User-specified output instantaneous frequency function (Hz); user-specified sweep fi(actual)(t) Actual output instantaneous frequency function (Hz); actual output sweep ychirp(t) Output chirp function

### Shaping the Frequency Sweep by Setting Frequency Sweep and Sweep Mode

The basic shape of the output instantaneous frequency sweep, fi(t), is set by the Frequency sweep and Sweep mode parameters, described in the following table.

Parameters for Setting Sweep ShapePossible SettingParameter Description

Frequency sweep

Linear

Logarithmic

Swept cosine

Determines whether the sweep frequencies vary linearly, quadratically, or logarithmically. Linear and swept cosine sweeps both vary linearly.

Sweep mode

Unidirectional

Bidirectional

Determines whether the sweep is unidirectional or bidirectional. For details, see Unidirectional and Bidirectional Sweep Modes

The following diagram illustrates the possible shapes of the frequency sweep that you can obtain by setting the Frequency sweep and Sweep mode parameters.

For information on how to set the frequency values in your sweep, see Setting Instantaneous Frequency Sweep Values.

### Unidirectional and Bidirectional Sweep Modes

The Sweep mode parameter determines whether your sweep is unidirectional or bidirectional, which affects the shape of your output frequency sweep (see Shaping the Frequency Sweep by Setting Frequency Sweep and Sweep Mode). The following table describes the characteristics of unidirectional and bidirectional sweeps.

Sweep Mode Parameter SettingsSweep Characteristics

`Unidirectional`

• Lasts for one Sweep time, Tsw

• Repeats once every Tsw

`Bidirectional`

• Lasts for twice the Sweep time, 2*Tsw

• Repeats once every 2*Tsw

• First half is identical to its unidirectional counterpart.

• Second half is a mirror image of the first half.

The following diagram illustrates a linear sweep in both sweep modes. For information on setting the frequency values in your sweep, see Setting Instantaneous Frequency Sweep Values.

### Setting Instantaneous Frequency Sweep Values

Set the following parameters to tune the frequency values of your output frequency sweep.

• Initial frequency (Hz), f0

• Target frequency (Hz), fi(tg)

• Target time (seconds), tg

The following table summarizes the sweep values at specific times for all Frequency sweep settings. For information on the formulas used to compute sweep values at other times, see Block Computation Methods.

Instantaneous Frequency Sweep Values

Frequency SweepSweep Value at
t = 0
Sweep Value at
t = tg
Time when Sweep Value Is Target Frequency, fi(tg)

Linear

f0

fi(tg)

tg

f0

fi(tg)

tg

Logarithmic

f0

fi(tg)

tg

Swept cosine

f0

2fi(tg) - f0

tg/2

### Block Computation Methods

The Chirp block uses one of two formulas to compute the block output, depending on the Frequency Sweep parameter setting. For details, see the following sections:

### Equations for Output Computation

The following table shows the equations used by the block to compute the user-specified output frequency sweep, fi(t), the block output, ychirp(t), and the actual output frequency sweep, fi(actual)(t). The only time the user-specified sweep is not the actual output sweep is when the Frequency sweep parameter is set to `Swept cosine`.

 Note   The following equations apply only to unidirectional sweeps in which fi(0) < fi(tg). To derive equations for other cases, you might find it helpful to examine the following table and the diagram in Shaping the Frequency Sweep by Setting Frequency Sweep and Sweep Mode.

The table below contains the following variables:

• fi(t) — the user-specified frequency sweep

• fi(actual)(t) — the actual output frequency sweep, usually equal to fi(t)

• y(t) — the Chirp block output

• $\psi \left(t\right)$ — the phase of the chirp signal, where $\psi \left(0\right)=0$, and $2\pi {f}_{i}\left(t\right)$ is the derivative of the phase

`${f}_{i}\left(t\right)=\frac{1}{2\pi }\cdot \frac{d\psi \left(t\right)}{dt}$`
• ${\varphi }_{0}$ — the Initial phase parameter value, where ${y}_{chirp}\left(0\right)=\mathrm{cos}\left({\varphi }_{0}\right)$

Equations Used by the Chirp Block for Unidirectional Positive Sweeps

Frequency SweepBlock Output Chirp SignalUser-Specified Frequency Sweep, fi(t)$\beta$Actual Frequency Sweep, fi(actual)(t)

`Linear`

$y\left(t\right)=\mathrm{cos}\left(\psi \left(t\right)+{\varphi }_{0}\right)$

${f}_{i}\left(t\right)={f}_{0}+\beta t$

$\beta =\frac{{f}_{i}\left({t}_{g}\right)-{f}_{0}}{{t}_{g}}$

${f}_{i}{{}_{\left(actual\right)}}^{\left(t\right)}={f}_{i}{}^{\left(t\right)}$

`Quadratic`

Same as `Linear`

${f}_{i}\left(t\right)={f}_{0}+\beta {t}^{2}$

$\beta =\frac{{f}_{i}\left({t}_{g}\right)-{f}_{0}}{{t}_{g}^{2}}$

${f}_{i}{{}_{\left(actual\right)}}^{\left(t\right)}={f}_{i}{}^{\left(t\right)}$

`Logarithmic`

Same as `Linear`

${F}_{i}\left(t\right)={f}_{0}{\left(\frac{{f}_{i}\left({t}_{g}\right)}{{f}_{0}}\right)}^{\frac{t}{{t}_{g}}}$

Where fi(tg) > f0> 0

N/A

${f}_{i\left(actual\right)}\left(t\right)={f}_{i}\left(t\right)$

`Swept cosine`

$y\left(t\right)=\mathrm{cos}\left(2\pi {f}_{i}\left(t\right)t+{\varphi }_{0}\right)$

Same as `Linear`

Same as `Linear`

${f}_{i\left(actual\right)}\left(t\right)={f}_{i}\left(t\right)+\beta t$

### Output Computation Method for Linear, Quadratic, and Logarithmic Frequency Sweeps

The derivative of the phase of a chirp function gives the instantaneous frequency of the chirp function. The Chirp block uses this principle to calculate the chirp output when the Frequency Sweep parameter is set to `Linear`, `Quadratic`, or `Logarithmic`.

 ${y}_{chirp}\left(t\right)=\mathrm{cos}\left(\psi \left(t\right)+{\varphi }_{0}\right)$ Linear, quadratic, or logarithmic chirp signal with phase $\psi \left(t\right)$ ${f}_{i}\left(t\right)=\frac{1}{2\pi }\cdot \frac{d\psi \left(t\right)}{dt}$ Phase derivative is instantaneous frequency

For instance, if you want a chirp signal with a linear instantaneous frequency sweep, you should set the Frequency Sweep parameter to `Linear`, and tune the linear sweep values by setting other parameters appropriately. The block outputs a chirp signal, the phase derivative of which is the specified linear sweep. This ensures that the instantaneous frequency of the output is the linear sweep you desired. For equations describing the linear, quadratic, and logarithmic sweeps, see Equations for Output Computation.

### Output Computation Method for Swept Cosine Frequency Sweep

To generate the swept cosine chirp signal, the block sets the swept cosine chirp output as follows.

 ${y}_{chirp}\left(t\right)=\mathrm{cos}\left(\psi \left(t\right)+{\varphi }_{0}\right)=\mathrm{cos}\left(2\pi {f}_{i}\left(t\right)t+{\varphi }_{0}\right)$ Swept cosine chirp output (Instantaneous frequency equation, shown above, does not hold.)

Note that the instantaneous frequency equation, shown above, does not hold for the swept cosine chirp, so the user-defined frequency sweep, fi(t), is not the actual output frequency sweep, fi(actual)(t), of the swept cosine chirp. Thus, the swept cosine output might not behave as you expect. To learn more about swept cosine chirp behavior, see Cautions Regarding the Swept Cosine Sweep and Equations for Output Computation.

### Cautions Regarding the Swept Cosine Sweep

When you want a linearly swept chirp signal, we recommend you use a linear frequency sweep. Though a swept cosine frequency sweep also yields a linearly swept chirp signal, the output might have unexpected frequency content. For details, see the following two sections.

### Swept Cosine Instantaneous Output Frequency at the Target Time is not the Target Frequency

The swept cosine sweep value at the Target time is not necessarily the Target frequency. This is because the user-specified sweep is not the actual frequency sweep of the swept cosine output, as noted in Output Computation Method for Swept Cosine Frequency Sweep. See the table Instantaneous Frequency Sweep Values for the actual value of the swept cosine sweep at the Target time.

### Swept Cosine Output Frequency Content May Greatly Exceed Frequencies in the Sweep

In Swept cosine mode, you should not set the parameters so that 1/Tsw is very large compared to the values of the Initial frequency and Target frequency parameters. In such cases, the actual frequency content of the swept cosine sweep might be closer to 1/Tsw, far exceeding the Initial frequency and Target frequency parameter values.

## Parameters

Frequency sweep

The type of output instantaneous frequency sweep, fi(t): `Linear`, `Logarithmic`, `Quadratic`, or `Swept cosine`.

Sweep mode

The directionality of the chirp signal: `Unidirectional` or `Bidirectional`.

Initial frequency (Hz)

For `Linear`, `Quadratic`, and `Swept cosine` sweeps, the initial frequency, f0, of the output chirp signal. For `Logarithmic` sweeps, Initial frequency is one less than the actual initial frequency of the sweep. Also, when the sweep is `Logarithmic`, you must set the Initial frequency to be less than the Target frequency. Tunable (Simulink).

Target frequency (Hz)

For `Linear`, `Quadratic`, and `Logarithmic` sweeps, the instantaneous frequency, fi(tg), of the output at the Target time, tg. For a `Swept cosine` sweep, Target frequency is the instantaneous frequency of the output at half the Target time, tg/2. When Frequency sweep is `Logarithmic`, you must set the Target frequency to be greater than the Initial frequency. Tunable (Simulink).

Target time (s)

For `Linear`, `Quadratic`, and `Logarithmic` sweeps, the time, tg, at which the Target frequency, fi(tg), is reached by the sweep. For a `Swept cosine` sweep, Target time is the time at which the sweep reaches 2fi(tg) - f0. You must set Target time to be no greater than Sweep time , ${T}_{sw}\ge {t}_{g}$. Tunable (Simulink).

Sweep time (s)

In `Unidirectional` Sweep mode, the Sweep time, Tsw, is the period of the output frequency sweep. In `Bidirectional` Sweep mode, the Sweep time is half the period of the output frequency sweep. You must set Sweep time to be no less than Target time, ${T}_{sw}\ge {t}_{g}$. Tunable (Simulink).

The phase, ${\varphi }_{0}$, of the cosine output at t=0; ${y}_{chirp}\left(t\right)=\mathrm{cos}\left({\varphi }_{0}\right)$. Tunable (Simulink).

Sample time

The sample period, Ts, of the output. The output frame period is Mo*Ts.

Samples per frame

The number of samples, Mo, to buffer into each output frame.

Output data type

The data type of the output, single-precision or double-precision.

## Examples

The first few examples demonstrate how to use the Chirp block's main parameters, how to view the output in the time domain, and how to view the output spectrogram:

Examples 4 and 5 illustrate Chirp block settings that might produce unexpected outputs:

### Example 1: Setting a Final Frequency Value for Unidirectional Sweeps

Often times, you might want a unidirectional sweep for which you know the initial and final frequency values. You can specify the final frequency of a unidirectional sweep by setting Target time equal to Sweep time, in which case the Target frequency becomes the final frequency in the sweep. The following model demonstrates this method.

This technique might not work for swept cosine sweeps. For details, see Cautions Regarding the Swept Cosine Sweep.

Open the Example 1 model by typing ex_chirp_ref at the MATLAB® command line. You can also rebuild the model yourself; see the following list for model parameter settings (leave unlisted parameters in their default states).

Since Target time is set to equal Sweep time (`1` second), the Target frequency (`25 `Hz) is the final frequency of the unidirectional sweep. Run your model to see the time domain output:

Type the following command to view the chirp output spectrogram:

```spectrogram(dsp_examples_yout,hamming(128),... 110,[0:.01:40],400) ```

 Chirp Block Parameters for Example 1 Frequency sweep `Linear` Sweep mode `Unidirectional` Initial frequency 0 Target frequency 25 Target time 1 Sweep time 1 Initial phase 0 Sample time 1/400 Samples per frame 400 Vector Scope Block Parameters for Example 1 Input domain `Time` Time display span 6 Signal To Workspace Block Parameters for Example 1 Variable name `dsp_examples_yout` Configuration Dialog Parameters for Example 1 Stop time 5

### Example 2: Bidirectional Sweeps

Change the Sweep mode parameter in the Example 1 model to `Bidirectional`, and leave all other parameters the same to view the following bidirectional chirp. Note that in the bidirectional sweep, the period of the sweep is twice the Sweep time (2 seconds), whereas it was one Sweep time (1 second) for the unidirectional sweep in Example 1.

Open the Example 2 model by typing `ex_chirp_ref2` at the MATLAB command line.

Run your model to see the time domain output:

Type the following command to view the chirp output spectrogram:

```spectrogram(dsp_examples_yout,hamming(128),... 110,[0:.01:40],400) ```

### Example 3: When Sweep Time is Greater Than Target Time

Setting Sweep time to `1.5` and leaving the rest of the parameters as in the Example 1 model gives the following output. The sweep still reaches the Target frequency (25 Hz) at the Target time (1 second), but since Sweep time is greater than Target time, the sweep continues on its linear path until one Sweep time (1.5 seconds) is traversed.

Unexpected behavior might arise when you set Sweep time greater than Target time; see Example 4: Output Sweep with Negative Frequencies for details.

Open the Example 3 model by typing `ex_chirp_ref3` at the MATLAB command line.

Run your model to see the time domain output:

Type the following command to view the chirp output spectrogram:

```spectrogram(dsp_examples_yout,hamming(128),... 110,[0:.01:40],400) ```

### Example 4: Output Sweep with Negative Frequencies

Modify the Example 1 model by changing Sweep time to `1.5`, Initial frequency to `25`, and Target frequency to `0`. The output chirp of this example might not behave as you expect because the sweep contains negative frequencies between 1 and 1.5 seconds. The sweep reaches the Target frequency of 0 Hz at one second, then continues on its negative slope, taking on negative frequency values until it traverses one Sweep time (1.5 seconds).

Open the Example 4 model by typing `ex_chirp_ref4` at the MATLAB command line.

Run your model to see the time domain output:

### Example 5: Output Sweep with Frequencies Greater Than Half the Sampling Frequency

Modify the Example 1 model by changing the Target frequency parameter to `275`. The output chirp of this model might not behave as you expect because the sweep contains frequencies greater than half the sampling frequency (`200 `Hz), which causes aliasing. If you unexpectedly get a chirp output with a spectrogram resembling the one following, your chirp's sweep might contain frequencies greater than half the sampling frequency.

Open the Example 5 model by typing `ex_chirp_ref5` at the MATLAB command line.

Run your model to see the time domain output:

Type the following command to view the chirp output spectrogram:

```spectrogram(dsp_examples_yout,hamming(64),... 60,256,400) ```

## Supported Data Types

• Double-precision floating point

• Single-precision floating point

 Signal From Workspace DSP System Toolbox Signal Generator Simulink Sine Wave DSP System Toolbox `chirp` Signal Processing Toolbox `spectrogram` Signal Processing Toolbox