plus, +
Matrix sum of fi
objects
Syntax
Description
is an alternate way to execute C
= plus(A
,B
)A + B
.
Note
For information about the fimath
properties involved in
Fixed-Point Designer™ calculations, see fimath Properties Usage for Fixed-Point Arithmetic and fimath ProductMode and SumMode.
Examples
This example shows how to use implicit expansion to add vectors and matrices with compatible dimensions.
Add Row and Column Vectors
Create a 3-by-1 column vector and 1-by-5 row vector and add them.
x = fi([1;2;3]); y = fi([1,2,3,4,5]); z = x + y
z = 2 3 4 5 6 3 4 5 6 7 4 5 6 7 8 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 18 FractionLength: 13
The result is a 3-by-5 matrix, where each (i,j)
element in the matrix is given by z(i,j) = x(i) + y(j)
.
Add Matrix and Column Vector
Create an M-by-N matrix and a M-by-1 column vector and add them.
x = fi([1 2 3 4 5 6 7 8 9 10 11 12 13 14 15]); y = fi([1;2;3]); z = x + y
z = 2 3 4 5 6 8 9 10 11 12 14 15 16 17 18 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 19 FractionLength: 13
The result is an M-by-N matrix, where each (i,j)
element in the matrix is given by z(i,j) = x(i,j) + y(i)
.
Add Matrix and Row Vector
Create a M-by-N matrix and a 1-by-N row vector and add them.
x = fi([1 2 3 4 5 6 7 8 9 10 11 12 13 14 15]); y = fi([1 2 3 4 5]); z = x + y
z = 2 4 6 8 10 7 9 11 13 15 12 14 16 18 20 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 18 FractionLength: 12
The result is an M-by-N matrix, where each (i,j) element in the matrix is given by z(i,j) = x(i,j) + y(j).
Add Matrix to Multidimensional Array
Create a M-by-N matrix and a M-by-N-by-P array and add them.
x = fi(ones(3,5)); y = fi(ones(3,5,3)); z = x + y
z = (:,:,1) = 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 (:,:,2) = 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 (:,:,3) = 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 17 FractionLength: 14
The result is an M-by-N-by-P array, where each (i,j,k) element in the array is given by z(i,j,k) = x(i,j) + y(i,j,k).
Input Arguments
Input array, specified as a scalar, vector, matrix, or multidimensional array of
fi
objects or built-in data types. Inputs A
and B
must either be the same size or have sizes that are
compatible. For more information, see Compatible Array Sizes for Basic Operations.
plus
does not support fi
objects of data
type boolean
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fi
Complex Number Support: Yes
Input array, specified as a scalar, vector, matrix, or multidimensional array of
fi
objects or built-in data types. Inputs A
and B
must either be the same size or have sizes that are
compatible. For more information, see Compatible Array Sizes for Basic Operations.
plus
does not support fi
objects of data
type boolean
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fi
Complex Number Support: Yes
Extended Capabilities
Usage notes and limitations:
Any non-
fi
inputs must be constant; that is, its value must be known at compile time so that it can be cast to afi
object.
Inputs cannot be of data type logical
.
Version History
Introduced before R2006aStarting in R2021b with the addition of implicit expansion for fi
times
, plus
, and minus
, some
combinations of arguments for basic operations that previously returned errors now produce
results.
If your code uses element-wise operators and relies on the errors that MATLAB® previously returned for mismatched sizes, particularly within a
try/catch
block, then your code might no longer catch those
errors.
For more information on the required input sizes for basic array operations, see Compatible Array Sizes for Basic Operations.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)