필터 지우기
필터 지우기

fprintf and for loop

조회 수: 10 (최근 30일)
Anna Cole
Anna Cole 2018년 10월 17일
편집: Dennis 2018년 10월 17일
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일
for i=1:10
for j=1:2
fprintf('period %d step %d \nsave\n',i,j)
end
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by