title: How to overcome an unexpected delay in comparator implementation in Simulink?
body: <p>I'm building a quite complicated model in Simulink. And I've noticed an unexpected delay. For simplicity, I've built a very simple model and I've found that again an unexpected delay was introduced.</p>
  
  <p>The simple model is just a comparator. It's defined inside a <em>Matlab Function Block</em> as: </p>
  
  <pre><code>if u &gt;= 2
    y = 3;
  elseif (u &lt; 2)
    y = -3;
  </code></pre>
  
  <p>The output is:</p>
  
  <p><a href="https://i.stack.imgur.com/jNMGq.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jNMGq.jpg" alt="enter image description here"></a></p>
  
  <p>As you can see, the blue wave doesn't move directly from +3 to -3 or from -3 to +3. However, there is a delay like 100 <em>usec.</em> <strong>Why is this??</strong> I mean according to the above function, it should move right away (change abruptly). <strong><em>And how can I make it change abruptly?</em></strong></p>