Values adding inside a loop

조회 수: 1 (최근 30일)
Auryn_
Auryn_ 2017년 1월 11일
편집: Stephen23 2017년 1월 11일
Hello, I am trying to create some data by using several loops inside loops. The thing is that instead of giving me the result that it would be without loop (I have taken the data alone to check the result), it gives me added values. It seems that after the first loop it doesn't "reset" and the next results are wrong. Any idea why this can happen? Thanks in advance.
  댓글 수: 2
dpb
dpb 2017년 1월 11일
'Cuz that's what you wrote the loops to do...now that may not be what you intended for said loops to do, but...
As for "why?", probably because indeed inside an outer loop you've not reinitialized a variable that needs must be that either isn't existent prior to the execution without the loop or had an initially-zero value.
How would you expect us to diagnose anything specific without the code, however????
Stephen23
Stephen23 2017년 1월 11일
편집: Stephen23 2017년 1월 11일
"Any idea why this can happen?"
Yes, several ideas. But you don't show us your code, so we will have to rely on our magical crystal balls to know what you code is doing. ooops, mine is broken today!

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

답변 (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