Avoid autoscaling of wordlength and fractionlength in fixed point objects

2 次查看(过去 30 天)
Hello, I set a fixed point object with wordlength 16 and fractionlength 4
x=ufi(16,12,4)
but when I make an operation on the object, the wordlength and fractionlength get changed, for example
y = sqrt(x)
scales those to 6 and 2 respectively.
How can I avoid this autoscaling?
Thanks!

回答(1 个)

MathWorks Fixed Point Team
SQRT function computes the square root of a fi object using a bisection algorithm.
You can use additional numerictype to control the output data types:
c = sqrt(a,T) returns the square root of fi object a with numerictype object T. Intermediate quantities are calculated using the fimath associated with a. See Data Type Propagation Rules.
x=ufi(16,12,4)
T = numerictype(0, 12, 4)
y = sqrt(x,T);
The choice of output data type without specifying T is documented as "internal rule" section of the function reference.

类别

Help CenterFile Exchange 中查找有关 Multirate Signal Processing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by