このページの翻訳は最新ではありません。ここをクリックして、英語の最新版を参照してください。
setfimath
fimath オブジェクトを fi
オブジェクトに付加
説明
は、y
= setfimath(x
,f
)x
の numerictype
と値をもち、fimath オブジェクト f
が付加されている fi
オブジェクト y
を返します。この関数および関連する関数 removefimath
は、両方のオペランドの embedded.fimath
が等しくなければならないというエラーを回避するのにも役立ちます。
構文 y
= setfimath(x
,f
) は入力 x
を変更しません。x
を変更するには、 x = setfimath(x,f)
を使用します。式で setfimath
を使用する場合 (a*setfimath(b,f)
など)、fimath オブジェクトは一時変数で使用されますが b
は変更されません。
例
fimath オブジェクトを fi オブジェクトに追加
fi
オブジェクトを定義して fimath
オブジェクトを定義し、setfimath
を使用して fimath
オブジェクトを fi
オブジェクトに追加します。
fimath
オブジェクトを含まない fi
オブジェクトの作成。
a = fi(pi)
a = 3.1416 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 13
fimath
オブジェクトを作成し、fi
オブジェクトに付加します。
f = fimath('OverflowAction','Wrap','RoundingMethod','Floor'); b = setfimath(a,f)
b = 3.1416 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 13 RoundingMethod: Floor OverflowAction: Wrap ProductMode: FullPrecision SumMode: FullPrecision
コード生成での fimath
の設定と削除
パターン x = setfimath(x,f)
と y = removefimath(y)
を使用すると、変数の fimath
設定が関数の外部から影響を受けないようにすることができます。このパターンは生成コードでデータのコピーを作成しません。
function y = fixed_point_32bit_KeepLSB_plus_example(a,b) f = fimath('OverflowAction','Wrap',... 'RoundingMethod','Floor',... 'SumMode','KeepLSB',... 'SumWordLength',32); a = setfimath(a,f); b = setfimath(b,f); y = a + b; y = removefimath(y); end
MATLAB® Coder™ 製品をお持ちの場合、C コードを生成できます。この例では、32 ビットのネイティブ整数型をもつコンピューターで C コードを生成します。
a = fi(0,1,16,15); b = fi(0,1,16,15); codegen -config:lib fixed_point_32bit_KeepLSB_plus_example... -args {a,b} -launchreport
int fixed_point_32bit_KeepLSB_plus_example(short a, short b) { return a + b; }
入力引数
x
— 入力データ
fi オブジェクト | 組み込み整数 | double | single
データ型と値を出力にコピーする fi
オブジェクトまたは組み込み整数値として指定する入力データです。x
は fi
オブジェクトまたは整数のデータ型 (int8
、int16
、int32
、int64
、uint8
、uint16
、uint32
または uint64
) でなければなりません。これ以外の場合は、fimath オブジェクトが適用されません。x
が fi
オブジェクトまたは整数のデータ型でない場合、y
= x
となります。
f
— 入力 fimath
オブジェクト
fimath
オブジェクト
出力に付加する既存の fimath オブジェクトとして指定された入力 fimath
オブジェクトです。f
が fimath
オブジェクトではない場合、エラーが発生します。
出力引数
拡張機能
C/C++ コード生成
MATLAB® Coder™ を使用して C および C++ コードを生成します。
バージョン履歴
R2012b で導入
参考
fi
| fimath
| removefimath
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)