title: From ODE45 take Angular acceleration MATLAB
body: <p>I'm solving the eqaution motion and I need numerical integration, so I decided to use ode45 in Matlab. I  found the displacement and the velocity, now I need to find the Angular acceleration and make plot with time.</p>
  
  <p>There's my code and function:</p>
  
  <p><b>Code</b>:</p>
  
  <pre><code>global r b m2 m3 m4 g I M
  
  % Quantities
  r=0.2;
  b=0.1;
  m2=1;
  m3=0.2;
  m4=2;
  g=9.81;
  tspan=0:0.01:2;
  
  % Calculation
  I=(m2*r^2)/3
  M0=m2*g*b+g*r*(m3+m4)
  M=1.2*M0
  
  % Runge- Kutta
  [t,x]=ode45(@funkce,tspan,[0 0]);
  
  % Plotting 
  figure(1);
  plot(t,x(:,2));
  grid;
  
  figure(2);
  plot(t,x(:,1));
  grid;
  </code></pre>
  
  <p><b>Function:</b></p>
  
  <pre><code>function v=funkce(t,x);
  
  global r b m2 m3 m4 g I M
  
  % Method
  v(1,1)= (x(1)^2*(m4*r^2*cos(x(2))*sin(x(2)))+M-cos(x(2))*m2*g*b+(m3+m4)*g*r)/(I+m3*r^2+m4*r^2*cos(x(2))^2);
  v(2,1)= x(1);
  </code></pre>