Element-by-element multiplication of fi
objects
Use the times
function to perform element-by-element multiplication of a fi
object and a scalar.
a=4; b=fi([2 4 7; 9 0 2])
b=2×3 object
2 4 7
9 0 2
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 11
a
is a scalar double, and b
is a matrix of fi
objects. When doing arithmetic between a fi
and a double, the double is cast to a fi
with the same word length and signedness of the fi
, and best-precision fraction length. The result of the operation is a fi
.
c=a.*b
c=2×3 object
8 16 28
36 0 8
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 32
FractionLength: 23
During the operation, a
was cast to a fi
object with wordlength 16. The output, c
, is a fi
object with word length 32, the sum of the word lengths of the two multiplicands, a
and b
. This is because the default setting of ProductMode
in fimath
is FullPrecision
.
Use the times
function to perform element-by-element multiplication of two fi
objects.
a=fi([5 9 9; 1 2 -3], 1, 16, 3)
a=2×3 object
5 9 9
1 2 -3
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 3
b=fi([2 4 7; 9 0 2], 1, 16, 3)
b=2×3 object
2 4 7
9 0 2
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 3
c=a.*b
c=2×3 object
10 36 63
9 0 -6
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 32
FractionLength: 6
The word length and fraction length of c
are equal to the sums of the word lengths and fraction lengths of a
and b
. This is because the default setting of ProductMode
in fimath
is FullPrecision
.
A
— Input arrayInput array, specified as a scalar, vector, matrix, or multidimensional array of
fi
objects or built-in data types.
A
and B
must have the same
dimensions unless one is a scalar value.
Data Types: fi
|single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
Complex Number Support: Yes
B
— Input arrayInput array, specified as a scalar, vector, matrix, or multidimensional array of
fi
objects or built-in data types.
A
and B
must have the same
dimensions unless one is a scalar value.
Data Types: fi
|single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
Complex Number Support: Yes
C
— Output arrayOutput array, returned as a scalar, vector, matrix, or multidimensional array.
Usage notes and limitations:
Any non-fi
input
must be constant; that is, its value must be known at compile time
so that it can be cast to a fi
object.
When you provide complex inputs to the times
function inside of a MATLAB® Function block, you must declare the input as
complex before running the simulation. To do so, go to the
Ports and data manager and set the
Complexity parameter for
all known complex inputs to
On
.
You have a modified version of this example. Do you want to open this example with your edits?