title: Create and plot a piecewise function in Octave
body: <p>So I want to plot this function</p>
  
  <p><img src="https://i.stack.imgur.com/82fSn.png" alt="enter image description here"></p>
  
  <p>for -1
  
  <p>First I created  the piecewise function</p>
  
  <pre><code>function x = pieceWise(t)
    if t &gt;= 0 &amp; t &lt;3
      x = exp(-t);
    else
      x = 0;
  endif
  </code></pre>
  
  <p>then called and plot it here</p>
  
  <pre><code>x = linspace(-1,5,1000);
  y = pieceWise(x);
  plot(x,y)
  </code></pre>
  
  <p>but the output is always 0</p>
  
  <p><img src="https://i.stack.imgur.com/JLmCj.png" alt="enter image description here"></p>
  
  <p>any hint would be very helpful. Thank you</p>