Main Content

sumblk

Summing junction for name-based interconnections

Syntax

S = sumblk(formula)
S = sumblk(formula,signalsize)
S = sumblk(formula,signames1,signames2,...)

Description

S= sumblk(formula)创建传递函数,S, of the summing junction described byformula. The character vectorformulaspecifies an equation that relates the scalar input and output signals ofS.

S= sumblk(formula,signalsize)returns a vector-valued summing junction. The input and output signals are vectors withsignalsizeelements.

S= sumblk(formula,signames1,signames2,...)replaces aliases (signal names beginning with%) informulaby the signal namessignames. The number ofsignamesarguments must match the number of aliases informula. The first alias informulais replaced bysignames1, the second bysignames2, and so on.

Input Arguments

formula

Equation that relates the input and output signals of the summing junction transfer functionS, specified as a character vector. For example, the following command:

S = sumblk('e = r - y + d')

creates a summing junction with input names'r','y', and'd', output name'e'and equatione = r-y+d.

If you specify asignalsizegreater than 1, the inputs and outputs ofSare vector-valued signals.sumblkautomatically performs vector expansion of the signal names ofS. For example, the following command:

S = sumblk('v = u + d',2)

specifies a summing junction with input names{'u(1)';'u(2)';'d(1)';'d(2)'}and output names{'v(1)';'v(2)'}. The formulas of this summing junction arev(1) = u(1) + d(1);v(2) = u(2) + d(2).

You can use one or more aliases informulato refer to signal names defined in a variable. An alias is a signal name that begins with%. Whenformulacontains aliases,sumblkreplaces each alias with the correspondingsignamesargument.

个性化别名是有用的,当你想要的名字l entries in a vector-valued signal. Aliases also allow you to use input or output names of existing models. For example, ifCandGare dynamic system models with nonemptyInputNameandOutputNameproperties, respectively, you can create a summing junction using the following expression.

S = sumblk('%e = r - %y',C.InputName,G.OutputName)

sumblkuses the values ofC.InputNameandG.OutputNamein place of%eand%y, respectively. The vector dimension ofC.InputNameandG.OutputNamemust match.sumblkassigns the signalrthe same dimension.

signalsize

Number of elements in each input and output signal ofS. Settingsignalsizegreater than 1 lets you specify a summing junction that operates on vector-valued signals.

Default:1

signames

Signal names to replace one alias (signal name beginning with%) in the argumentformula. You must provide onesignamesargument for each alias informula.

Specifysignamesas:

  • A cell array of signal names.

  • TheInputNameorOutputNameproperty of a model in the MATLAB®workspace. For example:

    S = sumblk('%e = r - y',C.InputName)

    This command creates a summing junction whose outputs have the same name as the inputs of the modelCin the MATLAB workspace.

Output Arguments

S

Transfer function for the summing junction, represented as a MIMOtfmodel object.

Examples

Summing Junction with Scalar-Valued Signals

Create the summing junction of the following illustration. All signals are scalar-valued.

This summing junction has the formulau = u1 + u2 + u3.

S = sumblk('u = u1+u2+u3');

Sis the transfer function (tf) representation of the sumu = u1 + u2 + u3. The transfer functionSgets its input and output names from the formula.

S.OutputName,S.Inputname
ans = 'u' ans = 'u1' 'u2' 'u3'

Summing Junction with Vector-Valued Signals

Create the summing junctionv = u - dwhereu,d,vare vector-valued signals of length 2.

S = sumblk('v = u-d',2);

sumblkautomatically performs vector expansion of the signal names ofS.

S.OutputName,S.Inputname
ans = 'v(1)' 'v(2)' ans = 'u(1)' 'u(2)' 'd(1)' 'd(2)'

Summing Junction with Vector-Valued Signals That Have Specified Signal Names

Create the summing junction

e ( 1 ) = setpoint ( 1 ) alpha + d ( 1 ) e ( 2 ) = setpoint ( 2 ) q + d ( 2 )

The signalsalphaandqhave custom names that are not merely the vector expansion of a single signal name. Therefore, use an alias in the formula specifying the summing junction.

S = sumblk('e = setpoint - %y + d', {'alpha';'q'});

sumblkreplaces the alias%ywith the cell array{'alpha';'q'}.

S.OutputName,S.Inputname
ans = 'e(1)' 'e(2)' ans = 'setpoint(1)' 'setpoint(2)' 'alpha' 'q' 'd(1)' 'd(2)'

Tips

  • Usesumblkin conjunction withconnectto interconnect dynamic system models and derive aggregate models for block diagrams.

Introduced in R2008a