Values adding inside a loop
조회 수: 1 (최근 30일)
이전 댓글 표시
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
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????
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!