fixpt_look1_func_approx
Optimize fixed-point approximation of nonlinear function by interpolating lookup table data points
Syntax
[
xdata
,ydata
,errworst
]
= fixpt_look1_func_approx('func
',...
xmin
,xmax
,xdt
,xscale
,ydt
,yscale
,rndmeth
,errmax
,nptsmax
)
[xdata
,ydata
,errworst
]
= fixpt_look1_func_approx('func
',...
xmin
,xmax
,xdt
,xscale
,ydt
,yscale
,rndmeth
,errmax
,[])
[xdata
,ydata
,errworst
]
= fixpt_look1_func_approx('func
',...
xmin
,xmax
,xdt
,xscale
,ydt
,yscale
,rndmeth
,[],nptsmax
)
[xdata
,ydata
,errworst
]
= fixpt_look1_func_approx('func
',...
xmin
,xmax
,xdt
,xscale
,ydt
ydt
,yscale
,rndmeth
,errmax
,nptsmax
,spacing
)
Description
[
returns
the optimal breakpoints of a lookup table, an ideal function applied
to the breakpoints, and the worst-case approximation error. The lookup
table satisfies the maximum acceptable error and maximum number of
points that you specify.xdata
,ydata
,errworst
]
= fixpt_look1_func_approx('func
',...
xmin
,xmax
,xdt
,xscale
,ydt
,yscale
,rndmeth
,errmax
,nptsmax
)
[
returns
the optimal breakpoints of a lookup table, an ideal function applied
to the breakpoints, and the worst-case approximation error. The lookup
table satisfies the maximum acceptable error that you specify.xdata
,ydata
,errworst
]
= fixpt_look1_func_approx('func
',...
xmin
,xmax
,xdt
,xscale
,ydt
,yscale
,rndmeth
,errmax
,[])
[
returns
the optimal breakpoints of a lookup table, an ideal function applied
to the breakpoints, and the worst-case approximation error. The lookup
table satisfies the maximum number of points that you specify.xdata
,ydata
,errworst
]
= fixpt_look1_func_approx('func
',...
xmin
,xmax
,xdt
,xscale
,ydt
,yscale
,rndmeth
,[],nptsmax
)
[
returns
the optimal breakpoints of a lookup table, an ideal function applied
to the breakpoints, and the worst-case approximation error. The lookup
table satisfies the maximum acceptable error, maximum number of points,
and breakpoint spacing that you specify.xdata
,ydata
,errworst
]
= fixpt_look1_func_approx('func
',...
xmin
,xmax
,xdt
,xscale
,ydt
ydt
,yscale
,rndmeth
,errmax
,nptsmax
,spacing
)
In each case, fixpt_look1_func_approx
interpolates
between lookup table data points to optimize the fixed-point approximation.
The inputs xmin
and xmax
specify
the range over which to approximate the breakpoints. The inputs xdt
, xscale
, ydt
, yscale
,
and rndmeth
follow conventions used by
fixed-point Simulink® blocks.
The inputs errmax
, nptsmax
,
and spacing
are optional. Of these inputs,
you must specify at least errmax
or nptsmax
.
If you omit one of those two inputs, you must use brackets, []
,
in place of the omitted input. fixpt_look1_func_approx
ignores
that requirement for the lookup table.
If you do not specify spacing, and more than one spacing satisfies errmax
and nptsmax
, fixpt_look1_func_approx
chooses
in this order: power-of-2 spacing, even spacing, uneven spacing. This
behavior applies when you specify both errmax
and nptsmax
,
but not when you specify just one of the two.
Input Arguments
|
Function of | ||||||||
|
Minimum value of | ||||||||
|
Maximum value of | ||||||||
|
Data type of | ||||||||
|
Scaling for the | ||||||||
|
Data type of | ||||||||
|
Scaling for the | ||||||||
|
Rounding mode supported by fixed-point Simulink blocks:
| ||||||||
|
Maximum acceptable error between the ideal function and the approximation given by the lookup table. | ||||||||
|
Maximum number of points for the lookup table. | ||||||||
|
Spacing of breakpoints for the lookup table:
|
If you specify... | The breakpoints of the lookup table... |
---|---|
| Meet both criteria, if possible. The |
| Meet the error criteria, and |
| Meet the points criteria, and |
Output Arguments
|
Vector of breakpoints for the lookup table. |
|
Vector of values from applying the ideal function to the breakpoints. |
|
Worst-case error, which is the maximum absolute error between the ideal function and the approximation given by the lookup table. |
Examples
Approximate a fixed-point sine function using a lookup table:
func = 'sin(2*pi*x)'; % Define the range over which to optimize breakpoints xmin = 0; xmax = 0.25; % Define the data type and scaling for the inputs xdt = ufix(16); xscale = 2^-16; % Define the data type and scaling for the outputs ydt = sfix(16); yscale = 2^-14; % Specify the rounding method rndmeth = 'Floor'; % Define the maximum acceptable error errmax = 2^-10; % Choose even, power-of-2 spacing for breakpoints spacing = 'pow2'; % Create the lookup table [xdata,ydata,errworst] = fixpt_look1_func_approx(func,... xmin,xmax,xdt,xscale,ydt,yscale,rndmeth,errmax,[],spacing);
Version History
Introduced before R2006a
See Also
fixpt_evenspace_cleanup
| fixpt_look1_func_plot
Topics
- Producing Lookup Table Data (Fixed-Point Designer)
- Use Lookup Table Approximation Functions (Fixed-Point Designer)