Main Content

removefimath

fimathfi オブジェクトから削除する

説明

y = removefimath(x) は、xnumerictype と値をもち、fimath オブジェクトは付加されていない fi オブジェクト y を返します。

この関数を y = removefimath(y) として使用すると、fimath 設定をローカルで制御できます。この関数は、両方のオペランドの embedded.fimath が等しくなければならないというエラーを回避するのにも役立ちます。

すべて折りたたむ

この例では、fi オブジェクトおよび fimath オブジェクトの定義方法、fi オブジェクトへの fimath オブジェクトの付加方法および付加された fimath オブジェクトの削除方法を説明します。

a = fi(pi)
a = 
    3.1416

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 16
        FractionLength: 13
f = fimath('RoundingMethod','Floor','OverflowAction','Wrap');
a = setfimath(a,f)
a = 
    3.1416

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 16
        FractionLength: 13

        RoundingMethod: Floor
        OverflowAction: Wrap
           ProductMode: FullPrecision
               SumMode: FullPrecision
b = removefimath(a)
b = 
    3.1416

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 16
        FractionLength: 13

この例では、パターン X = setfimath(X,F)Y = removefimath(Y) を使用して、変数の fimath 設定が関数の外部から影響を受けないようにする方法を示します。このパターンは生成コードでデータのコピーを作成しません。

type fixed_point_32bit_KeepLSB_plus_example.m
function y = fixed_point_32bit_KeepLSB_plus_example(a,b)
f = fimath('RoundingMethod', 'Floor', ...
           'OverflowAction', 'Wrap', ...
           'SumMode', 'KeepLSB', ...
           'SumWordLength', 32)

a = setfimath(a,f);
b = setfimath(b,f);

y = a + b;
y = removefimath(y);
end
a = fi(0,1,16,15);
b = fi(0,1,16,15);

MATLAB® Coder™ を使用して C コードを生成できます。この例では、32 ビットのネイティブ整数型をもつコンピューターで C コードを生成します。

codegen -config:lib  fixed_point_32bit_KeepLSB_plus_example...
       -args {a,b} -launchreport
Code generation successful: View report

コード生成レポートでコードをトレースします。

trace-code.png

入力引数

すべて折りたたむ

データ型と値を出力にコピーする元の入力データ。スカラー、ベクトル、行列または多次元配列として指定します。入力 xfi オブジェクトでない場合、y = x となります。

データ型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi
複素数のサポート: あり

出力引数

すべて折りたたむ

fimath が付加されていない fi オブジェクト。スカラー、ベクトル、行列または多次元配列として返されます。出力のデータ型と値は入力に一致します。入力 xfi オブジェクトでない場合、y = x となります。

拡張機能

C/C++ コード生成
MATLAB® Coder™ を使用して C および C++ コードを生成します。

バージョン履歴

R2012b で導入

参考

| |