Is it possible to have a vector input to a Simulink if-statement block?

I am working on vectorising my model and I got stuck when I tried to vectorise the if-statement block. I wonder if it is possible to do it in Simulink. I know that it will work if I get each singal individually and apply them to multiple of if-statement blocks, but this is not what I want to do. Any suggestions will be greatly appreciated!
This is what I want to do and the error that I get:

 채택된 답변

You can only apply scalars to the if port of action subsystems. Consider your example where you test:
out1_of_if_block = u1 == [1 2] = [1 0]
What do you expect the If Action Subsystem2 to do when [1 0] is applied to the action port?
Perhaps inside of the 'If' block, you would want to do something more like this:
u1(1) == 1

댓글 수: 3

Thank you so much for your answer. I wanted to check each element of the input vector with the scalar inside the if statement and obtain a vector output based on the result of this check. As you also stated, it seems I cannot do what I want with the if statements. I solved my problem with using the basic logical operators instead, which accept vector inputs.
Can u please show me how u did it? I'm having the same problem ):
@Ahmed Rashid @Tyene Zanella Any advice I am dealing with the same problem?

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 General Applications에 대해 자세히 알아보기

질문:

2015년 6월 25일

댓글:

2019년 8월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by