How to import a Symbolic Formula, so i can solve it with ode45 ?
    3 views (last 30 days)
  
       Show older comments
    
Im generating symbolic Formulas like
ddTheta1 =...
-(2*((m2*s2^2 + J2)*(l1*m2*s2*sin(T1 - T2)*dT2^2 + g*l1*m2*sin(T1) + g*m1*s1*sin(T1)) + (l1*m2^2*s2^2*(l1*sin(2*T1 - 2*T2)*dT1^2 - g*sin(T1) + g*sin(T1 - 2*T2)))/2))/(2*(m2*s2^2 + J2)*(m2*l1^2 + m1*s1^2 + J1) - l1^2*m2^2*s2^2*(cos(2*T1 - 2*T2) + 1))
ddTheta2 =...
(l1*m2*s2*sin(T1 - T2)*(m2*l1^2 + m1*s1^2 + J1)*dT1^2 - g*m2*s2*sin(T2)*(m2*l1^2 + m1*s1^2 + J1) + l1*m2*s2*cos(T1 - T2)*(l1*m2*s2*sin(T1 - T2)*dT2^2 + g*l1*m2*sin(T1) + g*m1*s1*sin(T1)))/((m2*s2^2 + J2)*(m2*l1^2 + m1*s1^2 + J1) - l1^2*m2^2*s2^2*cos(T1 - T2)^2)
How can i import it to this function, so i can solve it per ode45
function [ xp ] = x3punkt( t , x ) % mit J
global m1  m2  J1  J2  l1  l2  s1  s2  g  u1  u2 ddTheta1 ddTheta2
T1  = x(1); % Theta1
T2  = x(2); % Theta2
dT1 = x(3); % dTheta1
dT2 = x(4); % dTheta2
%    [ ddTheta1 , ddTheta2 ] = RTL_DGL;
ddTheta1 =...
-(2*((m2*s2^2 + J2)*(l1*m2*s2*sin(T1 - T2)*dT2^2 + g*l1*m2*sin(T1) + g*m1*s1*sin(T1)) + (l1*m2^2*s2^2*(l1*sin(2*T1 - 2*T2)*dT1^2 - g*sin(T1) + g*sin(T1 - 2*T2)))/2))/(2*(m2*s2^2 + J2)*(m2*l1^2 + m1*s1^2 + J1) - l1^2*m2^2*s2^2*(cos(2*T1 - 2*T2) + 1));
ddTheta2 =...
(l1*m2*s2*sin(T1 - T2)*(m2*l1^2 + m1*s1^2 + J1)*dT1^2 - g*m2*s2*sin(T2)*(m2*l1^2 + m1*s1^2 + J1) + l1*m2*s2*cos(T1 - T2)*(l1*m2*s2*sin(T1 - T2)*dT2^2 + g*l1*m2*sin(T1) + g*m1*s1*sin(T1)))/((m2*s2^2 + J2)*(m2*l1^2 + m1*s1^2 + J1) - l1^2*m2^2*s2^2*cos(T1 - T2)^2);
xp = [dT1; dT2; ddTheta1; ddTheta2];
end
Right now i just copy and paste the Formulas, but i would like to use something like this
[ ddTheta1 , ddTheta2 ] = RTL_DGL;
Thanks for your help
0 Comments
Answers (1)
  Star Strider
      
      
 on 10 Dec 2016
        I cannot figure out what you are doing. See the documentation for odeToVectorField and matlabFunction. They should help you do what you want.
The odeFunction function is also an option, but I’ve not used it.
2 Comments
  Steven Lord
    
      
 on 10 Dec 2016
				Use matlabFunction to convert the symbolic expression into a function or solve the system of ODEs symbolically using dsolve.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

