Fixed-Point Blockset    

Example 5: Using errmax with Power of Two Spacing

The next example shows how to construct a lookup table that has power of two spacing and a specified worst case error. To try the example, you must first enter the parameter values given in the section Setting Function Parameters for the Lookup Table, if you have not already done so in this MATLAB session.

Next, at the MATLAB prompt type

To find out how many points are in the lookup table, type

length(xdata)

This means that 33 points are required to achieve the worst case error specified by errmax. To verify that these points are evenly spaced, type

This generates a vector whose entries are the differences between consecutive points in xdata. Every entry of widths is 2-7.

To find the maximum error for the lookup table, type

errworst

This is less than the value of errmax.

To plot the lookup table data along with the errors, type

This displays the plots shown below.


  Example 4: Using nptsmax with Even Spacing Example 6: Using nptsmax with Power of Two Spacing