Values adding inside a loop
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
dpb
am 11 Jan. 2017
'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????
Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!