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 日

0 投票

for i=1:10
for j=1:2
fprintf('period %d step %d \nsave\n',i,j)
end
end

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

製品

リリース

R2018a

タグ

質問済み:

2018 年 10 月 17 日

編集済み:

2018 年 10 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by