How to neatly alternate between two different statements at different intervals
조회 수: 1 (최근 30일)
이전 댓글 표시
I'm struggling to figure out how I can use a for loop to execute two alternating statements at different intervals.
So in the interval ii=1:100, I want to execute one line of code when ii=[1:10, 21:30, 41:50, 61:70, 81:90] and the other line of code to execute when ii=[11:20, 31:40, 51:60, 71:80 91:100].
The best solution I've come up with is doing ten separate for loops one after the other... but I'm assuming this is the least efficient method to do this.
For context, the output here is an image being constantly changed from one state to another, back and forth, clearing the figure and showing the image at every interval.
Any help would be greatly appreciated - thank you!!
댓글 수: 0
채택된 답변
추가 답변 (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!