MATLAB: How to change the word length of a fi object with the Fixed-Point Toolbox 1.1 (R14SP1)

castfixedlengthpointword

I have a fi object with a 32-bit word length. How can I cast the object to have a different word length, such as 16 bits?

Best Answer

This enhancement has been incorporated in Release 2008a (R2008a). For previous product releases, read below for any possible workarounds:
In order to change the word length of a fi object, it is necessary to create a new fi object with the value of the original object, as in the example below.
a = fi(3);
b = fi(4);
F = fimath;
F.MaxProductWordLength = 32;
c = F.mpy(a,b);
%note that at this point, c has a word length of 32
c = fi(c,1,16);
%creates a new fixed-point object with the same properties as c, but with a word length of 16