fprintf and for loop

2 ビュー (過去 30 日間)
Anna Cole
Anna Cole 2018 年 10 月 17 日
編集済み: Dennis 2018 年 10 月 17 日
I want the following output:
period 1 step 1
save
period 1 step 2
save
period 2 step 1
save
and continue on in this manner.
I wrote the following code but I'm just getting it to print period (i) ten times over in one line.
for i=1:10
for j=1:2
fprintf("period (i)", "step (j)", '\n', '\t', "save")
end
end

採用された回答

Dennis
Dennis 2018 年 10 月 17 日
編集済み: Dennis 2018 年 10 月 17 日
for i=1:10
for j=1:2
fprintf('period %d step %d \nsave\n',i,j)
end
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by