fprintf and for loop

7 Ansichten (letzte 30 Tage)
Anna Cole
Anna Cole am 17 Okt. 2018
Bearbeitet: Dennis am 17 Okt. 2018
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
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 Programming finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by