fixpt_look1_func_plot
Plot fixed-point approximation function for lookup table
Syntax
fixpt_look1_func_plot(
xdata
,ydata
,'func
',...xmin
,xmax
,xdt
,xscale
,ydt
,yscale
,rndmeth
)errworst
= fixpt_look1_func_plot(xdata
,ydata
,'func
',...xmin
,xmax
,xdt
,xscale
,ydt
,yscale
,rndmeth
)
Description
fixpt_look1_func_plot(
plots a lookup table approximation function and the error from the ideal function.xdata
,ydata
,'func
',...xmin
,xmax
,xdt
,xscale
,ydt
,yscale
,rndmeth
)
plots a lookup table approximation function and the error from the ideal function. The outputerrworst
= fixpt_look1_func_plot(xdata
,ydata
,'func
',...xmin
,xmax
,xdt
,xscale
,ydt
,yscale
,rndmeth
)errworst
is the maximum absolute error.
You can usefixpt_look1_func_approx
to generatexdata
和ydata
,分别为查找表的断点和表数据。fixpt_look1_func_approx
applies the ideal function to the breakpoints inxdata
to produceydata
. While this method is the easiest way to generateydata
, you can choose other values forydata
as input forfixpt_look1_func_plot
. Choosing different values forydata
can, in some cases, produce a lookup table with a smaller maximum absolute error.
Input Arguments
|
Vector of breakpoints for the lookup table. |
||||||||
|
Vector of values from applying the ideal function to the breakpoints. |
||||||||
|
功能 |
||||||||
|
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®块:
|
Examples
Plot a fixed-point approximation of the sine function using data points generated byfixpt_look1_func_approx
:
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'; % Generate data points for the lookup table [xdata,ydata,errworst]=fixpt_look1_func_approx(func,... xmin,xmax,xdt,xscale,ydt,yscale,rndmeth,errmax,[],spacing); % Plot the sine function (ideal and fixed-point) & errors fixpt_look1_func_plot(xdata,ydata,func,xmin,xmax,... xdt,xscale,ydt,yscale,rndmeth);
fixpt_look1_func_plot
plots the fixed-point sine function, using generated data points, and plots the error between the ideal function and the fixed-point function. The maximum absolute error and the number of points required appear on the plot. The error drops to zero at a breakpoint, but increases between breakpoints due to curvature differences between the ideal function and the line drawn between breakpoints.
The lookup table requires 33 points to achieve a maximum absolute error of2^-11.3922
.
See Also
fixpt_evenspace_cleanup
|FIXPT_INTERP1
|fixpt_look1_func_approx
Topics
- Producing Lookup Table Data(定点设计师)
- 使用查找表近似功能(定点设计师)