title: Discretization for plotting trajectory of dynamic system in Matlab
body: <p>Suppose I have the following dynamic system</p>
  
  <p>\dot{x} = x(x-0.5)(x+0.5)</p>
  
  <p>So I know the region of attraction is in [-0.5,0.5]  </p>
  
  <p>So given x0 in this region, this state should go to 0 as t goes to infinity</p>
  
  <p>In matlab, I want to see such trajectory, so I use the following common way:</p>
  
  <p>x(t+1) = x(t) + dt*f(x)  </p>
  
  <pre><code>x0 = [-.3;-.1;.3] % 3D case
  dt = .01;
  num = 1;
  for t = dt : dt : tf
      num = num + 1;
          x(:,num) = x(:,num - 1) + dt*([x(1)^3-0.25*x(1);x(2)^3-0.25*x(2);x(3)^3-0.25*x(3)] );
  end 
  </code></pre>
  
  <p>It seems that all three trajectories do not converge to 0. Is there any problem with my codes? </p>
  
  <p><a href="https://i.stack.imgur.com/aWBZC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aWBZC.png" alt="enter image description here"></a></p>