How to make a time controlled multi port switch?

조회 수: 3 (최근 30일)
Andrea Angella
Andrea Angella 2017년 3월 6일
답변: Sonam Gupta 2017년 3월 9일
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.

답변 (1개)

Sonam Gupta
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.

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by