This is machine translation

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

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Generate Chirp Signal

This example shows how to generate a linear chirp signal on ThingSpeak™. A chirp is a signal in which the frequency increases (up-chirp) or decreases (down-chirp) with time. This example shows a linear chirp that consecutively changes from up-chirp to down-chirp depending on the pairity of the minute when the visualization is run.

Define the Chirp Signal Generator

Set the initial frequency of the chirp to be 0 Hz and the target frequency (frequency at the end of the sweep) to be 10 Hz. The frequency sweep is set to occur in the target time of 10 seconds. Given that the maximum instantaneous frequency of the signal is 10 Hz, to prevent aliasing, set the sample rate to 50. Also, set the samples per frame to 500 to ensure that you get a full sweep.

hchirp = dsp.Chirp( ...
    'InitialFrequency', 0,...
    'TargetFrequency', 10, ...
    'TargetTime', 10, ...
    'SweepTime', 100, ...
    'SampleRate', 50, ...
    'SamplesPerFrame', 500);

Generate the Chirp Signal

Generate the chirp using the step function. Use the minute of evaluation to provide a continuously sweeping nature to the chirp.

chirpData = (step(hchirp))';
evenFlag = mod(minute(datetime('now')),2);
if evenFlag
    chirpData = fliplr(chirpData);

Plot the Chirp Signal

Use plot to plot the chirp signal.


Add the chirp visualization using MATLAB Visualizations App. The chirp ramp changes direction when refreshed on even or odd minutes.

See Also


System Objects