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.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Generate discrete sine wave

The `dsp.SineWave`

System
object™ generates a real or complex, multichannel sinusoidal signal with independent
amplitude, frequency, and phase in each output channel.

For both real and complex sinusoids, the Amplitude,
Frequency, and PhaseOffset properties can be scalars or length-*N* vectors, where
*N* is the number of channels in the output. When you specify at least one
of these properties as a length-*N* vector, scalar values specified for the
other properties are applied to each of the *N* channels.

To generate a discrete-time sinusoidal signal:

Create the

`dsp.SineWave`

object and set its properties.Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects? (MATLAB).

`sine = dsp.SineWave`

`sine = dsp.SineWave(Name,Value)`

`sine = dsp.SineWave(amp,freq,phase,Name,Value)`

creates a sine wave
object that generates a real-valued sinusoid with an amplitude of 1, a frequency of 100
Hz, and a phase offset of 0. By default, the sine wave object generates only one
sample.`sine`

= dsp.SineWave

creates a sine wave object with each specified property set to the specified value.
Enclose each property name in single quotes. `sine`

= dsp.SineWave(`Name,Value`

)

creates a sine wave object with the Amplitude property set to `sine`

= dsp.SineWave(amp,freq,phase,`Name,Value`

)`amp`

, Frequency property set to `freq`

,
PhaseOffset property set to `phase`

,
and anyother specified properties set to the specified values.

**For versions earlier than R2016b, use the step
function to run the System object algorithm. The arguments to
step are the object you created, followed by
the arguments shown in this section.**

**For example, y = step(obj,x) and y = obj(x) perform equivalent operations.**

`sineOut = sine()`

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)