Hi all! How can I rewrite this for loop in a while?
for i = 2:sum(1: (rows - 1))
if (i > sum(1: (x)))
x ++;
endif
if ( (i == sum(1:(x))) || (i == sum(1: (x - 1)) + 1))
A(i,i) = 5;
else
A(i,i) = 6;
endif
endfor

 채택된 답변

David Hill
David Hill 2020년 4월 17일

0 개 추천

i=2;
while i <= sum(1:rows-1)
if i > sum(1:x)
x=x+1;
end
if (i == sum(1:x)) || (i == sum(1:x-1)+1)
A(i,i) = 5;
else
A(i,i) = 6;
end
i=i+1;
end

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

태그

질문:

2020년 4월 17일

답변:

2020년 4월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by