Main Content

for

指定された回数繰り返す for ループ

構文

for index = values
   statements
end

説明

for index = values, statements, end はループでステートメントのグループを指定された回数実行します。

fi オブジェクトによる colon, : 演算がインデックスとして使用される場合、fi オブジェクトは 0 または正の整数でなければなりません。

詳細は、MATLAB® 関数 for のリファレンス ページを参照してください。

すべて折りたたむ

for ループのインデックスとして fi オブジェクトを使用します。

a = fi(1,0,8,0);
b = fi(2,0,8,0);
c = fi(10,0,8,0);

for x = a:b:c
 x
end
x = 
     1

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Unsigned
            WordLength: 8
        FractionLength: 0
x = 
     3

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Unsigned
            WordLength: 8
        FractionLength: 0
x = 
     5

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Unsigned
            WordLength: 8
        FractionLength: 0
x = 
     7

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Unsigned
            WordLength: 8
        FractionLength: 0
x = 
     9

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Unsigned
            WordLength: 8
        FractionLength: 0

拡張機能

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

バージョン履歴

R2014b で導入