fm = get_fimath();
idx = fi(1,0,1,0,fm);
a = (idx+fi(2,0,2,0,fm))*fi(1/3,0,16,17,fm);
k = fi(a,0,17,0,fm)
function fm = get_fimath()
fm = fimath('RoundingMethod', 'Floor',...
This code is generated when using the Matlab Coder . I want to know why is k equal to zero? Is it because of division 1/3?
Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.
It's just like scientific notation
is the short answer to "Why FractionLength can be bigger than WordLength?".
The long answer is the following.
The concept of a binary-point is very useful for initial understanding of fixed-point types. Similarly, the concept of a decimal-point is useful for understanding values beyond integers. But using decimal-points becomes very cumbersome for very big or very small numbers. To make it easy to represent very big or very small values, scientific notation is super valuable.
verySmallNumber = 3e-200;
veryBigNumber = 7e123;
In essence, this notation breaks the value into two parts, a mantissa and an integer exponent for the given base.
Y = mantissa .* 10.^exponent
Fixed-point follows the same concept except that
- base is 2
- mantissa must be an integer
- exponent is fixed, i.e. it is part of the variables type and does not change for the life of the variable
Y = intMantissa .* 2^FixedExponent
SEE COMPLETE ANSWER CLICK THE LINK
Why do the data become zero when using the function fi?
rendra_ehsa fm = get_fimath(); idx = fi(1,0,1,0,fm); a = (idx+fi(2,0,2,0,fm))*fi(1/3,0,16,17,fm); k = fi(a,0,17,0,fm)…