Switch Case when a value stagnates
이전 댓글 표시
Suppose I have a switch case scenario and a variable, var which records a value from a for-loop as such:
1st loop: var=10
2nd loop: var=9
3rd loop: var=9
4th loop: var=8
5th loop: var=8
6th loop: var=8
7th loop: var=8
8th loop: var=8
9th loop: var=8
When any value (in this case 8) is repeated for 3 times, I need to switch from case 1 to case 2. Now the question is, how can I check if a value is repeated 3 times?
In the case above, the first switch is performed when the value 8 is repeated 3 times (4th-6th iteration); and the second switch is performed the next series of value 8 is repeated for 3 times (7th-9th iteration).
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 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!