title: How can I create a piecewise inline function in MATLAB?
body: <p>I have a function in MATLAB which takes another function as an argument. I would like to somehow define a piecewise inline function that can be passed in. Is this somehow possible in MATLAB?</p>
  
  <p>Edit: The function I would like to represent is:</p>
  
  <pre><code>f(x) = { 1.0,  0.0 &lt;= x &lt;= 0.5,
           -1.0, 0.5 &lt; x &lt;= 1.0
  
  where 0.0 &lt;= x &lt;= 1.0
  </code></pre>