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

 Respuesta aceptada

Dennis
Dennis el 17 de Oct. de 2018
Editada: Dennis el 17 de Oct. de 2018

0 votos

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

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Productos

Versión

R2018a

Etiquetas

Preguntada:

el 17 de Oct. de 2018

Editada:

el 17 de Oct. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by