Switch multiport switch inputs based on time and order from user

조회 수: 22 (최근 30일)
Yazeed
Yazeed 2024년 12월 10일 19:25
편집: Fangjun Jiang 2024년 12월 11일 13:49
I have a multiport switch with 6 inputs in simulink and would like the user to input an order of which inputs to select and for how long, is this possible. For example, the user wants the model to start at input 4 and stay there for 5 seconds, then select input 1 for 10 seconds, and finally select input 3 for 7 seocnds.

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2024년 12월 10일 20:01
편집: Fangjun Jiang 2024년 12월 11일 13:49
There are many ways to do it. The easiest or most flexible way to do it is probably by using a MATLAB Function block. Use a Clock block as an input which provides the simulation time, use if-elseif to determine the timing and provide the output, which could be the direct selection of those 6 inputs, or the index used by the downstream Multi-port Switch block to select the inputs.
Other ways:
  1. Use Relational Operator blocks and Switch Blocks (cascaded)
  2. Use If block and If Action Subsystem block
  3. Use 1-D Lookup Table block
  댓글 수: 2
Yazeed
Yazeed 2024년 12월 10일 20:09
편집: Yazeed 2024년 12월 10일 20:10
The issue Im running into using this method is "Simulink cannot propagate the variable-size mode. The multi-port switch expects a fixed-size mode."
Fangjun Jiang
Fangjun Jiang 2024년 12월 10일 21:02
편집: Fangjun Jiang 2024년 12월 10일 21:02
Then the output of the MATLAB Function block is not right. It should be a scalar if it is connected to a downstream multiport switch block. Debug the MATLAB Function block alone. Its output should always be a scalar number between 1 to 6 (or 0 to 5 if zero-based).

댓글을 달려면 로그인하십시오.

카테고리

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

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by