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

 Accepted Answer

Dennis
Dennis on 17 Oct 2018
Edited: Dennis on 17 Oct 2018
for i=1:10
for j=1:2
fprintf('period %d step %d \nsave\n',i,j)
end
end

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products

Release

R2018a

Tags

Asked:

on 17 Oct 2018

Edited:

on 17 Oct 2018

Community Treasure Hunt

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

Start Hunting!