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!