Generate various waveforms
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:
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.
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 Solver||Signal Generator Block Output|
The Signal Generator block outputs a scalar or array of real signals of type double.
For more information, see Data Types Supported by Simulink in the Simulink documentation.
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.
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.
Specify the signal amplitude. The default is 1.
Specify the signal frequency. The default is 1.
Specify the signal units as Hertz or rad/sec. The default is rad/sec.
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.
The following Simulink examples show how to use the Signal Generator block:
Yes, of parameters