nrnw
nrnw

Reputation: 531

Using if function in MATLAB Simulink

I have created the following block diagram on Matlab Simulink. It should give OUT1=1 OUT2=0 when INPUT>=0 and OUT1=0 OUT2=1 when INPUT<0. But it does not give the expected results. What is the reason for that. Any advice to make it work correctly would be appreciated.

enter image description here

Upvotes: 0

Views: 4814

Answers (3)

Phil Goddard
Phil Goddard

Reputation: 10762

The behaviour you are seeing can be explained by noting the following:

  • The output from the If Subsystem acts like an enable signal.
  • By default, the Output Ports of an If Action Subsystem are set to hold their values when the (sub)system is disabled.

This can be changed by going to the parameters dialog of the Output Port (within the If Action Subsystems) and changing the Output when disabled property to reset. You'll also want to change the default value to zero.

Upvotes: 3

Daniel
Daniel

Reputation: 36710

In many cases an IF is translated to a switch. You calculate cases and select the one which is intended. Here you could connect a constant [1 0] and a constant [0 1] to the first and third input and the sign block from your solution to the second input.

Upvotes: 1

nrnw
nrnw

Reputation: 531

This if function block thing didn't work. So I come up with a different approach to get the result I wanted using the sign block. Solution is posted below. Thank you for everyone for trying to help.

enter image description here

Upvotes: 0

Related Questions