Documentation

Waveform Generator

Output waveforms using signal notations

Description

The Waveform Generator block outputs waveforms based on signal notations that you enter in theWaveform Definitiontable.

This block supports these syntaxes for the signal notations:

  • Function syntax — Specify all arguments in the specific order for the signal syntax (seeAlgorithms).

  • Name-value syntax — Specify optional comma-separated pairs ofName,Valuearguments.Nameis the argument name andValueis the corresponding value.Namemust appear inside single quotes (' '). You can specify several name and value pair arguments in any order asName1,Value1,...,NameN,ValueN.For more information, seeAlgorithms

This block supports normal, accelerator, and rapid accelerator modes and fast restart.

Supported Operators

Operation Operator

Absolute value

abs()

Addition

+

Division

/

Multiplication

*

Parentheses

()

Subtraction

-

Unary minus

-

The Waveform block observes the following rules of operator precedence:

  1. ( )

  2. + -(unary)

  3. * /

  4. + -

Supported Operations

TheWaveform Generatorblock outputs one signal at a time. You can change this output signal. Express frequency and phase offset parameters in radians. You can also:

  • Nest signal notations, for example:

    sin('Amplitude',sin('Amplitude',1,'Frequency',1,'Phase',0),'Frequency',1,'Phase',1)

  • Reference real scalar variables in the base or model workspace, for example:

    sin('Amplitude',x,'Frequency',y,'Phase',z)

    x,y, andzexist in the base workspace.

For more information on waveforms, see the Algorithms section.

To quickly determine the response of a system to different types of inputs, you can vary the output signal of theWaveform Generatorblock while a simulation is in progress.

Limitations

Ports

Output

expand all

Output signal specified by an entry in theWaveform Definitiontable.

Data Types:single|double|int8|int16|int32|uint8|uint16|uint32|Boolean|fixed point|bus

Parameters

expand all

Main

Select waveform definition to specify the output signal. The number corresponds to the line item in theWaveform Definitiontable. You can change this parameter while a simulation is running.

Programmatic Use

Block Parameter:SelectedSignal
Type: character vector
Values: scalar
Default:'1'

Enter signal notations in theWaveform Definitiontable, one waveform definition per line. For syntax details, see Algorithms.

Signal Attributes

Click theShow data type assistantbuttonto display theData Type Assistant, which helps you set the data type attributes. SeeSpecify Data Types Using Data Type Assistantfor more information.

Lower value of the output range that Simulink checks.

Simulink uses the minimum to perform:

Note

Output minimumdoes not saturate or clip the actual output signal. Use theSaturationblock instead.

Programmatic Use

Block Parameter:OutMin
Type: character vector
Values:'[ ]'| scalar
Default:'[ ]'

Upper value of the output range that Simulink checks.

Simulink uses the maximum value to perform:

Note

Output maximumdoes not saturate or clip the actual output signal. Use theSaturationblock instead.

Programmatic Use

Block Parameter:OutMax
Type: character vector
Values:'[ ]'| scalar
Default:'[ ]'

Choose the data type for the output. The type can be inherited, specified directly, or expressed as a data type object such asSimulink.NumericType

Programmatic Use

Block Parameter:OutDataTypeStr
Type: character vector
Values: ,'Inherit: Inherit via back propagation','single','int8','uint8',int16,'uint16','int32','uint32',fixdt(1,16,0),fixdt(1,16,2^0,0),fixdt(1,16,2^0,0)''
Default:'Double'

Select to lock the output data type setting of this block against changes by the Fixed-Point Tool and the Fixed-Point Advisor. For more information, seeUse Lock Output Data Type Setting(Fixed-Point Designer).

Programmatic Use

Block Parameter:LockScale
Type: character vector
Values:'off'|'on'
Default:'off'

Select to lock data type settings of this block against changes by the Fixed-Point Tool and the Fixed-Point Advisor.

Programmatic Use

Block Parameter:LockScale
Values:'off' | 'on'
Default:'off'

See Also

For more information, seeLock the Output Data Type Setting(Fixed-Point Designer).

Choose one of these rounding modes.

Ceiling

Rounds both positive and negative numbers toward positive infinity. Equivalent to the MATLAB®ceilfunction.

Convergent

Rounds number to the nearest representable value. If a tie occurs, rounds to the nearest even integer. Equivalent to the Fixed-Point Designer™convergentfunction.

Floor

Rounds both positive and negative numbers toward negative infinity. Equivalent to the MATLABfloorfunction.

Nearest

Rounds number to the nearest representable value. If a tie occurs, rounds toward positive infinity. Equivalent to the Fixed-Point Designernearestfunction.

Round

Rounds number to the nearest representable value. If a tie occurs, rounds positive numbers toward positive infinity and rounds negative numbers toward negative infinity. Equivalent to the Fixed-Point Designerroundfunction.

Simplest

Automatically chooses between round toward floor and round toward zero to generate rounding code that is as efficient as possible.

Zero

Rounds number toward zero. Equivalent to the MATLABfixfunction.

Programmatic Use

Block Parameter:RndMeth
Type: character vector
Values:'Ceiling'|'Convergent'|'Floor'|'Nearest'|'Round'|'Simplest'|'Zero'
Default:'Floor'

See Also

For more information, seeRounding(Fixed-Point Designer)

Specify whether overflows saturate or wrap.

Action Rationale Impact on Overflows Example

Select this check box (on).

Your model has possible overflow, and you want explicit saturation protection in the generated code.

Overflows saturate to either the minimum or maximum value that the data type can represent.

The maximum value that theint8(签署了8位整数)数据类型可以表示127. Any block operation result greater than this maximum value causes overflow of the 8-bit integer. With the check box selected, the block output saturates at 127. Similarly, the block output saturates at a minimum output value of -128.

Do not select this check box (off).

You want to optimize efficiency of your generated code.

You want to avoid overspecifying how a block handles out-of-range signals. For more information, seeCheck for Signal Range Errors

Overflows wrap to the appropriate value that is representable by the data type.

The maximum value that theint8(签署了8位整数)数据类型可以表示127. Any block operation result greater than this maximum value causes overflow of the 8-bit integer. With the check box cleared, the software interprets the overflow-causing value asint8, which can produce an unintended result. For example, a block result of 130 (binary 1000 0010) expressed asint8, is -126.

When you select this check box, saturation applies to every internal operation on the block, not just the output, or result. Usually, the code generation process can detect when overflow is not possible. In this case, the code generator does not produce saturation code.

Programmatic Use

Block Parameter:SaturateOnIntegerOverflow
Type:character vector
Values:'off' | 'on'
Default:'off'

Specify the time interval between samples. To inherit the sample time, set this parameter to-1.SeeSpecify Sample Timefor more information.

Programmatic Use

Block Parameter:SampleTime
Type: character vector
Values: scalar
Default:'0.1'

Algorithms

expand all

Enter signal notations in theWaveform Definitiontable, one waveform definition per line. To add a waveform definition, clickAdd.The new waveform appears as an empty character vector. The block interprets empty character vectors or white space character vectors as ground.

To remove a waveform definition, clickRemove.You can select multiple waveforms usingCtrl+click orShift+click.

Introduced in R2015b

Was this topic helpful?