How to convert from a for loop to a while loop

i got stuck how to change this code from for loop to a while loop ,may someone help

댓글 수: 4

Please don't post code as pictures ... we can't copy & run pictures. Post code as text and format it with the CODE button.
abood sal
abood sal 2020년 4월 28일
편집: per isakson 2020년 4월 28일
COPOALL = zeros(59,13);
%co1
for i = 1:13
if AllstudentsResult (2,i)==1
for j=1:59
COPOALL(j,1) = COPOALL(j,1) + AllstudentsResult(j+3,i);
end
else
for j=1:59
COPOALL(j,1) = COPOALL(j,1) + 0;
end
end
end
abood - which for loop do you want to convert to a while loop? All three?
yes

댓글을 달려면 로그인하십시오.

답변 (1개)

Eva-Maria Weiss
Eva-Maria Weiss 2020년 4월 30일
편집: Eva-Maria Weiss 2020년 4월 30일
j = 1
while j <= 59
COPOALL(j,1) = COPOALL(j,1) + AllstudentsResult(j+3,i);
j = j + 1;
end
Maybe something like that? The same for the other for loops....
But why to replace? :)
Good luck!!!

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2020년 4월 28일

편집:

2020년 4월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by