I have a nonlinear dynamical system. I have forund the eqautions of motion, which results in the following state vector:
The variables I used are
I keep getting all kinds of errors. What am I foing wrong. Thank you!
function f = fun_1(t,x)m0 = 0.25; m1 = 0.1; m2= 0.08;L1 = 0.25; L2 = 0.2;g = 9.81;F = 0;f=zeros(6,1);f(1) =x(2);f(2) =(-(L1*cos(x(3))*(m1+2*m2))/(2*(m0+m1+m2)))*f(4)+(-(m2*L2*cos(x(5)))/(2*(m0+m1+m2)))*f(6)+((L1*sin(x(3))*(m1+2*m2))/(2*(m0+m1+m2)))*x(4)^2+((m2*L2*sin(x(5)))/(2*(m0+m1+m2)))*x(6)^2+(2*F/(2*(m0+m1+m2)));f(3) =x(4);f(4) =(-(6*L1*cos(x(3))*(m1+2*m2))/(4*L1^2*(m1+3*m2)))*f(2)+(-(6*m2*L1*L2*cos(x(3)-x(5)))/(4*L1^2*(m1+3*m2)))*f(6)+(-(6*m2*L1*L2*sin(x(3)-x(5)))/(4*L1^2*(m1+3*m2)))*x(6)^2+((6*g*L1*(m1+2*m2)*sin(x(-(6*m2*L1*L2*sin(x(3)-x(5)))/3)))/(4*L1^2*(m1+3*m2)));f(5) =x(6);f(6) =(-(6*m2*L2*cos(x(5)))/(4*m2*L2^2))*f(2)+(-(6*m2*L1*L2*cos(x(3)-x(5)))/(4*m2*L2^2))*f(4)+(-(6*m2*L1*L2*sin(x(3)-x(5)))/(4*m2*L2^2))*x(4)^2+((6*m2*g*L2*sin(x(5)))/(4*m2*L2^2));clcclear allclose alltspan = [0 10];x0=[0;0;0;0;0;0];[t, x] = ode23('fun_1', tspan, x0);plot(t,x(:,3))xlabel('t')ylabel('theta(t)')
Best Answer