我有一个非线性动力系统。我找到了运动方程,它产生了以下状态向量:
我使用的变量是
我不断收到各种错误。我究竟做错了什么。谢谢!
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));
clc
clear all
close all
tspan = [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)')