How to make a time controlled multi port switch?
4 次查看(过去 30 天)
显示 更早的评论
Hello. I want to alternate between a set of inputs using a multi port switch block controlled by an imput control signal that varies in time. To make it more clear, imagine I have 3 data ports and 1 control input. I want to alternate between the 3 data ports every second. How can I do this? I was thinking, can I somehow make an input control signal that is a step function that has value 1 for 0<t<1, 2 for 1<t<2 and 3 for 2<t<3 and so on, periodically and use it as control input for the multiport switch? If so, how can I do this? Thank you.
0 个评论
回答(1 个)
Sonam Gupta
2017-3-9
Using a ramp function and mod function will help you to achieve a periodic signal that will behave like step function. It will have value as 0 when t belongs to [0, 1), 1 when t belongs to [1,2) and 2 when t belongs to [2, 3). By doing mod of ramp function with 3 you will always get values in range of 0 to 3. Note that for this logic you need to use Zero based contiguous ordering for input ports. Set 'data port order' property in multi port switch block parameters to 'Zero-based contiguous'.
I have attached a dummy model with the file. It uses three constant blocks as input and in the scope block attached to multi port switch, you can observe the periodic output.
Hope this helps.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sources 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!