fixpt_look1_func_plot
ルックアップ テーブルの固定小数点近似関数をプロットする
構文
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
)
説明
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
)errworst
は最大絶対誤差です。
fixpt_look1_func_approx
を使って xdata
と ydata
、つまり、ルックアップ テーブルのブレークポイントとテーブル データを生成できます。fixpt_look1_func_approx
は理想関数を xdata
のブレークポイントに適用して ydata
を生成します。この方法が最も簡単な ydata
の生成方法ですが、fixpt_look1_func_plot
への入力として ydata
には別の値を選択できます。ydata
用に異なる値を選択すると、場合によっては、最大絶対誤差が小さいルックアップ テーブルを作成することができます。
入力引数
|
ルックアップ テーブルのブレークポイントのベクトル。 | ||||||||
|
ブレークポイントに理想関数を適用して得た値のベクトル。 | ||||||||
|
ブレークポイントの近似に使用する | ||||||||
|
| ||||||||
|
| ||||||||
|
| ||||||||
|
| ||||||||
|
| ||||||||
|
| ||||||||
|
固定小数点の Simulink® ブロックでサポートされる丸め処理モード。
|
例
fixpt_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
は生成されたデータ点を使って固定小数点正弦関数をプロットし、さらに、理想関数と固定小数点関数との間の誤差をプロットします。グラフには、最大絶対誤差と必要なデータ点の数も表示されます。ブレークポイントの位置では誤差がゼロになり、ブレークポイント間では、理想関数の曲線とブレークポイント間に引いた線との違いのために曲率の誤差が大きくなります。
このルックアップ テーブルでは、2^-11.3922
の最大絶対誤差を実現するためには 33 個のポイントが必要です。
バージョン履歴
R2006a より前に導入
参考
fixpt_evenspace_cleanup
| fixpt_look1_func_approx
トピック
- ルックアップ テーブル データの生成 (Fixed-Point Designer)
- ルックアップ テーブルの近似関数の使用 (Fixed-Point Designer)