how we write condition in for loop?

suppose in c language we have a condition like k=0;k<j;k++
how we write this code in matlab?

 採用された回答

Raj
Raj 2019 年 4 月 3 日

0 投票

k=0;
while k<j
k=k+1
end

その他の回答 (2 件)

Pruthvi G
Pruthvi G 2019 年 4 月 3 日
編集済み: Pruthvi G 2019 年 4 月 3 日

0 投票

Increment of 1
for k = 1:1:j % Increment of 1
% do operations
end
Increment of 2
for k = 1:2:j % Increment of 2
% do operations
end
Decrement from j to 1 in step of 1
for k = j:-1:1 % Decrement of -1
% do operations
end
Please Accept answer if you understood, else ping me for advanced help

1 件のコメント

Sanjoy Dey
Sanjoy Dey 2019 年 4 月 3 日
k<j how its work?

サインインしてコメントする。

Sanjoy Dey
Sanjoy Dey 2019 年 4 月 3 日
編集済み: Sanjoy Dey 2019 年 4 月 3 日

0 投票

i know syntax of for loop--- for index=initial value : step size: final value
but i want to know the condition k<j,how i write this condition?

カテゴリ

ヘルプ センター および File ExchangeMATLAB Coder についてさらに検索

タグ

質問済み:

2019 年 4 月 3 日

編集済み:

2019 年 4 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by