title: How to create an if statement based on multiple conditions?
body: <p>I'm trying to implement an <code>if</code> condition in Matlab that when two objects get at a distance of 30 meters of each other should accelerate until 100 m and after that it should behave normal. The condition should not work when the distance gets lower than 100 m but only when it reaches 29 m or below, until 100 m.</p>
  
  <p>As I've read, Matlab will only take the first statement from the left so I was thinking to write the condition in 2 steps, but got stuck.</p>
  
  <p>This is what I've done so far:</p>
  
  <pre><code>%%%%functia ----osc----simplu
  function yprim=osccar1(t,y)
  global dist1
  if dist1&lt;30
      antr=1;
  elseif dist1&gt;30
      antr=1;
  end
  if dist1&lt;100
      bntr=1;
  else
      bntr=2;
  end
  %    if dist1&lt;30 &amp;&amp; (dist1&lt;100)
  %         indth=1;
  %    elseif dist1&lt;100
  %        indth=1;
  %    else
  %         indth=0;
  %     end
  
  magn=(y(1)^2+y(2)^2+y(3)^2)^(3/2);
  yprim=zeros(6,1);
  % if indth==1
  if antr==bntr
      yprim(1,1)=y(4);
      yprim(2,1)=y(5)-0.001;
      yprim(3,1)=y(6);
      yprim(4,1)=double(y(1)/magn);
      yprim(5,1)=double(y(2)/magn);
      yprim(6,1)=double(y(3)/magn);
  else
      yprim(1,1)=y(4);
      yprim(2,1)=y(5);
      yprim(3,1)=y(6);
      yprim(4,1)=double(y(1)/magn);
      yprim(5,1)=double(y(2)/magn);
      yprim(6,1)=double(y(3)/magn);
  end
  </code></pre>