필터 지우기
필터 지우기

For loop is not working

조회 수: 1 (최근 30일)
Adan91h
Adan91h 2017년 3월 3일
댓글: Adan91h 2017년 3월 4일
i"m trying to map values of Y(:,:,k) to specific positions of YT(:,:,alpha) but this code is not working.
for alpha=1:NumberofLines
YT(:,:,alpha) = Y(:,:,k);
alpha= j+1
j=j+j
k=k+1
if (alpha > NumberofLines)
break
end
end
Please help!

채택된 답변

Image Analyst
Image Analyst 2017년 3월 3일
Where did you set j? Also, redefining your loop iterator, alpha, inside the loop is not advisable. You can do it, but when it gets to the bottom of the loop, it takes on the value from the "for" line, it does not retain the value you set it to. And why are you setting j equal to j+j?
  댓글 수: 1
Adan91h
Adan91h 2017년 3월 4일
Thank you so much for your help. I introduced new variable for loop iterator (not using alpha anymore) and now loop works fine.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by