1より小さい数でループ計算を実行するには?

2 visualizaciones (últimos 30 días)
nktkis
nktkis el 15 de En. de 2022
Respondida: Atsushi Ueno el 15 de En. de 2022
1より小さい数でループ計算を実行するには,どんなプログラムを記述すれば良いですか?
具体的には,while文を用いて0.5刻みで計算したいです.

Respuestas (1)

Atsushi Ueno
Atsushi Ueno el 15 de En. de 2022
x = -2; % 例として変数xに2を設定
while x < 1
x % ここで変数xを使って計算する
x = x + 0.5;
end
x = -2
x = -1.5000
x = -1
x = -0.5000
x = 0
x = 0.5000

Categorías

Más información sobre ループと条件付きステートメント en Help Center y File Exchange.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!