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

 Akzeptierte Antwort

Dennis
Dennis am 17 Okt. 2018
Bearbeitet: Dennis am 17 Okt. 2018

0 Stimmen

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

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2018a

Tags

Gefragt:

am 17 Okt. 2018

Bearbeitet:

am 17 Okt. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by