Main Content

fixpt_look1_func_approx

通过插入查找表数据点来优化非线性函数的定点逼近

语法

[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,ydtydt,yscale,rndmeth,errmax,nptsmax,spacing)

说明

[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,ydtydt,yscale,rndmeth,errmax,nptsmax,spacing)
返回查找表的最优断点、应用于断点的理想函数以及最差情形逼近误差。查找表满足您指定的最大可接受误差、最大点数和断点间距。

在每种情况下,fixpt_look1_func_approx 都会在查找表数据点之间进行插值以优化定点逼近。xminxmax 输入值指定要逼近断点的范围。xdtxscaleydtyscalerndmeth 输入值遵循定点 Simulink® 模块使用的约定。

errmaxnptsmaxspacing 输入值为可选项。在这些输入中,必须至少指定 errmaxnptsmax。如果省略这两个输入中的一个,则必须使用方括号 [] 替代省略的输入。fixpt_look1_func_approx 会忽略查找表的该要求。

如果不指定间距,并且有多个间距满足 errmaxnptsmax,则 fixpt_look1_func_approx 按以下顺序选择:2 次幂间距、等间距、非等间距。当您同时指定 errmaxnptsmax 而不是仅指定两者之一时,此行为适用。

输入参数

func

用于逼近断点的 x 的函数。将此表达式括在单引号中,例如 'sin(2*pi*x)'

xmin

x 的最小值。

xmax

x 的最大值。

xdt

x 的数据类型。

xscale

x 值的定标。

ydt

y 的数据类型。

yscale

y 值的定标。

rndmeth

定点 Simulink 模块支持的舍入模式:

'Ceiling'

朝正无穷方向舍入到最邻近的可表示数字。

'Floor'(默认值)

朝负无穷方向舍入到最邻近的可表示数字。

'Nearest'

舍入到最邻近的可表示数字。

'Toward Zero'

朝零方向舍入到最邻近的可表示数字。

errmax

理想函数和查找表给出的近似值之间的最大可接受误差。

nptsmax

查找表的最大点数。

spacing

查找表的断点间距:

'even'等间距
'pow2'均匀 2 次幂间距
'unrestricted'(默认值)非等间距
如果您指定...查找表的断点...

errmaxnptsmax

如果可能,同时满足这两个条件。

errmax 要求的优先级高于 nptsmax。如果断点不能以指定的间距同时满足这两个条件,则 nptsmax 不适用。

errmax

满足误差条件,并且 fixpt_look1_func_approx 返回最少点数。

nptsmax

满足点数条件,并且 fixpt_look1_func_approx 返回最小最差情形误差。

输出参量

xdata

查找表的断点向量。

ydata

将理想函数应用到断点所获得的值的向量。

errworst

最差情形误差,是理想函数和查找表给出的近似值之间的最大绝对误差。

示例

使用查找表逼近定点正弦函数:

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);

版本历史记录

在 R2006a 之前推出