Main Content

for

Boucle for à répéter le nombre de fois indiqué

Syntaxe

for index = values
   statements
end

Description

exemple

for index = values, statements, end exécute un groupe d'instructions dans une boucle répétée le nombre de fois indiqué.

Si une opération colon, : incluant des objets fi est utilisée en tant qu’index, les objets fi doivent être des nombres entiers.

Pour plus d’informations, veuillez vous reporter à la page de référence MATLAB® for.

Exemples

réduire tout

Utilisez un objet fi en tant qu’index d’une boucle for.

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

Capacités étendues

Génération de code C/C++
Générez du code C et C++ avec MATLAB® Coder™.

Historique des versions

Introduit dans R2014b