Multiple if conditions are met simultaneously when IF Block in Simulink is used, why?

Hi all,
I am giving the following 5 conditions to the If Block inside an enabled subsystem. During the period of which the subsystem is enabled, the inputs to the If Block remain constant.
(u1 > u2)&(u1 > u3)&(u1 > u4)&(u1 > u5)
(u2 > u1)&(u2 > u3)&(u2 > u4)&(u2 > u5)
(u3 > u1)&(u3 > u2)&(u3 > u4)&(u3 > u5)
(u4 > u1)&(u4 > u2)&(u4 > u3)&(u4 > u5)
(u5 > u1)&(u5 > u2)&(u5 > u3)&(u5 > u4)
There can only be one maximum and hence there should only be one condition that is met.
This scope shows the input to the If Block:
u1, u2, u3, u4, and u5 are pink, blue, orange, green, and purple, respectively.
The output of the If Block shows that multiple conditions are met at the same time.
This Scope shows the nth condition that is met:
However, there was supposed to be only one output (as there can only one maximum) and there rest of the signals were supposed to be zero.
This is my Enabled Subsystem:
Can someone explain this unexpected behavior? Thanks!

5 Comments

You do not appear to be using a Merge block. The values that were computed earlier are potentially still on the lines.
Hello Walter, Thanks for pointing that out.
I tried using the Merge block and received the following error:
Branched signals cannot be fed into a Merge block. The signal from 'New_approach_v2/Enabled Subsystem/Signal Conversion4' output port 1 is connected to both Merge block 'New_approach_v2/Enabled Subsystem/Merge' input port 1 and to 'New_approach_v2/Enabled Subsystem/MultiSwitch Select1' input port 1. To fix this error, you can insert a Signal Conversion block in Signal Copy mode and feed the output of the Signal Conversion block to only the Merge block.
Then I tried using the Signal Conversion block as the error message suggested but it didn't solve the problem.
What am I doing wrong?
Hello Walter, Thanks for pointing that out.
I tried using the Merge block and received the following error:
Branched signals cannot be fed into a Merge block. The signal from 'New_approach_v2/Enabled Subsystem/Signal Conversion4' output port 1 is connected to both Merge block 'New_approach_v2/Enabled Subsystem/Merge' input port 1 and to 'New_approach_v2/Enabled Subsystem/MultiSwitch Select1' input port 1. To fix this error, you can insert a Signal Conversion block in Signal Copy mode and feed the output of the Signal Conversion block to only the Merge block.
Then I tried using the Signal Conversion block as the error message suggested but it didn't solve the problem.
What am I doing wrong?
---- EDIT -----
I found out that Scope was causing the issue removing it solved the problem. I didn't know that Scope could be be considered branching. Thank you again.
Hi,
I am facing a similar issue where I have multiple condition on if block and it executes true if any one is fulfilled?
@Canberk Suat Gurel did you find the solution?

Sign in to comment.

Answers (0)

Categories

Find more on Simulink in Help Center and File Exchange

Products

Release

R2017b

Asked:

on 21 May 2018

Community Treasure Hunt

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

Start Hunting!