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 Kommentare

James Tursa
James Tursa am 28 Apr. 2020
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 am 28 Apr. 2020
Bearbeitet: per isakson am 28 Apr. 2020
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
Geoff Hayes
Geoff Hayes am 29 Apr. 2020
abood - which for loop do you want to convert to a while loop? All three?
abood sal
abood sal am 30 Apr. 2020
yes

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Eva-Maria Weiss
Eva-Maria Weiss am 30 Apr. 2020
Bearbeitet: Eva-Maria Weiss am 30 Apr. 2020

0 Stimmen

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!!!

Kategorien

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

Gefragt:

am 28 Apr. 2020

Bearbeitet:

am 30 Apr. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by