Accelerating the pace of engineering and science

• Trials

# Signal Generator

Generate various waveforms

Sources

## Description

### Supported Operations

The Signal Generator block can produce one of four different waveforms: sine wave, square wave, sawtooth wave, and random wave. You can express signal parameters in Hertz (the default) or radians per second. Using default parameter values, you get one of the following waveforms:

WaveformScope Output

Sine wave

Square wave

Sawtooth wave

Random wave

A negative Amplitude parameter value causes a 180-degree phase shift. You can generate a phase-shifted wave at other than 180 degrees in many ways. For example, you can connect a Clock block signal to a MATLAB Function block and write the equation for the specific wave.

You can vary the output settings of the Signal Generator block while a simulation is in progress. This is useful to determine quickly the response of a system to different types of inputs.

The Amplitude and Frequency parameters determine the amplitude and frequency of the output signal. The parameters must be of the same dimensions after scalar expansion. If you clear the Interpret vector parameters as 1-D check box, the block outputs a signal of the same dimensions as the Amplitude and Frequency parameters (after scalar expansion). If you select the Interpret vector parameters as 1-D check box, the block outputs a vector (1-D) signal if the Amplitude and Frequency parameters are row or column vectors, that is, single row or column 2-D arrays. Otherwise, the block outputs a signal of the same dimensions as the parameters.

### Solver Considerations

If your model uses a fixed-step solver, Simulink® uses the same step size for the entire simulation. In this case, the Signal Generator block output provides a uniformly sampled representation of the ideal waveform.

If your model uses a variable-step solver, Simulink might use different step sizes during the simulation. In this case, the Signal Generator block output does not always provide a uniformly sampled representation of the ideal waveform. To ensure that the block output is a uniformly sampled representation, add a Hit Crossing block directly downstream of the Signal Generator block. The following models show the difference in Signal Generator block output with and without the Hit Crossing block.

Model That Uses a Variable-Step SolverSignal Generator Block Output

## Data Type Support

The Signal Generator block outputs a scalar or array of real signals of type double.

## Parameters and Dialog Box

Wave form

Specify the wave form: a sine wave, square wave, sawtooth wave, or random wave. The default is a sine wave. This parameter cannot change while a simulation is running.

Time

Specify whether to use simulation time as the source of values for the waveform's time variable or an external signal. If you specify an external time source, the block displays an input port for the time source.

Amplitude

Specify the signal amplitude. The default is 1.

Frequency

Specify the signal frequency. The default is 1.

Units

Specify the signal units as Hertz or rad/sec. The default is rad/sec.

Interpret vector parameters as 1-D

If selected, column or row matrix values for the Amplitude and Frequency parameters result in a vector output signal (see Determining the Output Dimensions of Source Blocks). This option is not available when an external signal specifies time. In this case, if the Amplitude and Frequency parameters are column or row matrix values, the output is a 1-D vector.

## Examples

The following Simulink examples show how to use the Signal Generator block:

## Characteristics

 Sample Time Continuous Scalar Expansion Yes, of parameters Dimensionalized Yes Multidimensionalized Yes Zero-Crossing Detection No