Main Content

dsp.ArrayVectorAdder

(Removed) Add array to vector along specified dimension

dsp.ArrayVectorAdder has been removed. Use the + operator instead. For more information, see Compatibility Considerations.

Description

The ArrayVectorAdder object adds an N-D array to a vector along a specified dimension. The length of the vector must equal the size of the N-D array along the specified dimension.

To add an N-D array to a vector along a specified dimension:

  1. Define and set up your array-vector addition object. See Construction.

  2. Call step to add the N-D array according to the properties of dsp.ArrayVectorAdder. The behavior of step is specific to each object in the toolbox.

Note

Starting in R2016b, instead of using the step method to perform the operation defined by the System object™, you can call the object with arguments, as if it were a function. For example, y = step(obj,x) and y = obj(x) perform equivalent operations.

Construction

ava = dsp.ArrayVectorAdder returns an array-vector addition object, ava, that adds a vector to an N-D array along the first dimension.

ava = dsp.ArrayVectorAdder('PropertyName',PropertyValue, ...) returns an array-vector addition object, ava, with each property set to the specified value.

Properties

Dimension

Dimension along which to add vector elements to input

Specify the dimension along which to add the input array to the elements of the vector as a positive integer. The length of the vector must match the size of the N-D array along the specified dimension. The default is 1.

VectorSource

Source of vector

Specify the source of the vector values as |Input port | Property |. The default is Input port.

Vector

Vector values

Specify the vector values. This property applies only when you set the VectorSource property to Property. The default is [0.5 0.25]. This property is tunable.

 Fixed-Point Properties

Methods

stepAdd vector to N-D array
Common to All System Objects
release

Allow System object property value changes

Examples

collapse all

Note

If you are using R2016a or an earlier release, replace each call to the object with the equivalent step syntax. For example, obj(x) becomes step(obj,x).

Add a 2-by-1 vector to a 2-by-2 matrix along the first dimension of the array.

ava = dsp.ArrayVectorAdder;
a = ones(2);
x = [1 2]';
y = ava(a, x);

Algorithms

This object implements the algorithm, inputs, and outputs described on the Array-Vector Add block reference page. The object properties correspond to the block parameters, except:

The array-vector addition object does not have Minimum or Maximum options for data output.

Extended Capabilities

Version History

Introduced in R2012a

expand all

R2023a: dsp.ArrayVectorAdder System object has been removed

The dsp.ArrayVectorAdder System object has been removed. Use the + operator instead.

Update Code

This table shows how to update existing code to use the + operator.

Discouraged UsageRecommended Replacement

Add along first dimension (column-wise)

ava = dsp.ArrayVectorAdder(Dimension=1);
a = ones(2);
x = [1 2]';
y = ava(a,x)
y = 2×2

     2     2
     3     3

Add along first dimension (column-wise)

y = a + x
y = 2×2

     2     2
     3     3

Add along second dimension (row-wise)

ava = dsp.ArrayVectorAdder(Dimension=2);
a = ones(2);
x = [1 2];
y = ava(a,x)
y = 2×2

     2     3
     2     3

Add along second dimension (row-wise)

y = a + x
y = 2×2

     2     3
     2     3

Add along Nth dimension

d = [3 10 2 3 4];
a = randn(d);

Sum the array with a vector along the fourth dimension.

N = 4;
ava = dsp.ArrayVectorAdder(Dimension=N);
x = randn(1,d(N));
y = ava(a,x);

Add along Nth dimension

C = repmat({1},1,length(d));
C{N} = ':';
xN(C{:}) = x;
yNew = a + xN
all(y == yNew,'all')
ans =

  logical

   1