Increment and decrement counter
14 次查看(过去 30 天)
显示 更早的评论
Hello,
How to increment counter upto 5 and after reaching to 5 start decrement it till 0 and again start increment from 0 to 5 and from 5 to 0 continuously, by using simulink blocks.
Thank you
0 个评论
回答(1 个)
Fangjun Jiang
2020-7-19
Use a 'Unit Delay' block. That is the counter. Add a number to it. The number is either 1 or -1.
Use S-R Flip-Flop block to generate the number. Its output is either 1 or 0 but you can multiple it by 2 and then minus 1 to get either 1 or -1.
Compare the counter value with 5 and 0 to get the Set and Reset signal for the S-R Flip-Flop block.
3 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Additional Math and Discrete 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!